G-46. Disjoint Set | Union by Rank | Union by Size | Path Compression

  Рет қаралды 240,659

take U forward

take U forward

Жыл бұрын

In this video, I have shown you such a code snippet, which can solve any problem on Disjoint Set on any platform.
C++ Code Snippet of DS: ide.geeksforgeeks.org/392f3f8...
Java Code Snippet of DS: ide.geeksforgeeks.org/fde794b...
C++/Java/Codes and Notes Link: takeuforward.org/data-structu...
DP Series: • Striver's Dynamic Prog...
SDE Sheet: takeuforward.org/interviews/s...
Check out our Website for curated resources:
Our Second Channel: / @striver_79
In case you are thinking to buy courses, please check below:
Code "takeuforward" for 15% off at GFG: practice.geeksforgeeks.org/co...
Code "takeuforward" for 20% off on sys-design: get.interviewready.io?_aff=takeuforward
Crypto, I use the Wazirx app: wazirx.com/invite/xexnpc4u
Take 750 rs free Amazon Stock from me: indmoney.onelink.me/RmHC/idje...
Earn 100 rs by making a Grow Account for investing: app.groww.in/v3cO/8hu879t0
Linkedin/Instagram/Telegram: linktr.ee/takeUforward
---------------------------------------------------------------------------------------------------------------------------

Пікірлер: 359
@takeUforward
@takeUforward Жыл бұрын
Let's continue the habit of commenting “understood” if you got the entire video. Please give it a like too,. Do follow me on Instagram: striver_79
@prem263
@prem263 Жыл бұрын
Hi, During example explanation, you have mentioned to update parent of u or parent of v depending on rank of parent of u and v. but in code you are updating parent[ulp_u] which is parent of ultimate parent of u at 29:19. Can you please clarify why is this difference.
@cartube6219
@cartube6219 Жыл бұрын
java ka code likh k kya hi matlab , jab aap samjhate nhi , jesaa c++ ka code likhte ho vesaa live java ka likha rao app plz ,, c++ ka code side me chika diya karo , c++ community bahut badi hai , woh help leke manage kr lenge ,, but java walo ka kya ??
@abhikantkumar8833
@abhikantkumar8833 Жыл бұрын
​@@cartube6219 bro both java and c++ are almost same , there are only some minor syntax difference.
@sudhanshushekhar4222
@sudhanshushekhar4222 Жыл бұрын
Understood
@abhinavgupta8839
@abhinavgupta8839 2 ай бұрын
HIndi wala chiye solutions
@crazyduniya128
@crazyduniya128 Жыл бұрын
Me looking here nd there while video is playing, then suddenly I looked at the striver's face and found that he is more serious about my career then I myself. This motivated me and my focus boosted. Thank you striver. 🙏😌
@sohailshaik9
@sohailshaik9 Жыл бұрын
Watching this video after watching Abdul Bari sir's video. Both are legends in their own way. Great learning ❤️
@yashkagi5399
@yashkagi5399 Жыл бұрын
i used to watch abdul bari's video for sleeping as his voice is very monotonous
@vm1662
@vm1662 11 ай бұрын
Same! I just watched Abdul Bari sir's video and now watching Striver. These two are blessings to CS students.
@movieskingdom1748
@movieskingdom1748 10 ай бұрын
Khud se bhi karle bhai..sirf video dekhne se kuch ni hota.
@shubhamkumar-hx1fb
@shubhamkumar-hx1fb 4 ай бұрын
​@@yashkagi5399😂
@shubhamkumar-hx1fb
@shubhamkumar-hx1fb 4 ай бұрын
​@@movieskingdom1748 khud se questions kiye jate Hain algos ke to videos hi dekhne padte hain 😂
@valarmorghulis9244
@valarmorghulis9244 11 ай бұрын
This was the toughest topic in Graph. So in case someone finds it difficult to understand while watching it for the first time. I suggest you to watch the next few videos and come back and do some brainstorming and then again see this video. I tell you this because it worked for me. And clearly no other videos have this depth explanation on KZfaq. You will know how beautifully Striver has explained once the working of Disjoint Sets starts ticking your mind. Just watch some of the next videos and then come back and watch this.
@lavanyam3224
@lavanyam3224 3 ай бұрын
yes you're right, after watching the next few videos, it makes more sense. I also watched Tushar roy's video on Disjoint sets, it helped too :)
@AbhinavSingh-rl9zr
@AbhinavSingh-rl9zr 13 күн бұрын
wow literally blown my mind such depth of covering each point with intutition..,.massive amount of practice and hardwork is behind all this..
@tiyashaghosh9933
@tiyashaghosh9933 Жыл бұрын
The more I see his videos, his work, the more I respect him.
@sanyamjawlia
@sanyamjawlia Жыл бұрын
Please bring such more series of other topics as well. These series are too amazing and easy to understand. Loved your way of teaching as well.
@cool.kunalsikri
@cool.kunalsikri Жыл бұрын
In college, i never did coding even though i was in Cse branch. Because i never liked competetive programming. But after coming into tech industry, i started liking to code and solve problems. So i have started learning various ds and i must say the content u have created is awesome. I love it .Awesome explanations . Thanks brother!
@sameerakhatoon9508
@sameerakhatoon9508 Жыл бұрын
can you please lmk w/ which job you started?
@varunaggarwal7126
@varunaggarwal7126 Жыл бұрын
same with me.
@musharrafhussain130
@musharrafhussain130 11 ай бұрын
systumm!
@rollercoaster9719
@rollercoaster9719 10 ай бұрын
now the biggest qn is, how the hell did u get a job if u never did coding in college
@shibainu7500
@shibainu7500 4 ай бұрын
@@rollercoaster9719 Aisa hi hota tha
@cinime
@cinime Жыл бұрын
Understood! Such an awesome explanation as always, thank you very much!!
@SoniaStalance
@SoniaStalance Жыл бұрын
Wow! That was one of the best tutorials I've ever seen.
@ashishkumaryadav5252
@ashishkumaryadav5252 Жыл бұрын
Exceptional content on KZfaq. Hats Off
@jayyanthmalepati7584
@jayyanthmalepati7584 Жыл бұрын
I did understood the class partially not fully but striver's videos have a good content .literally he is my trainer
@animeshmondal9569
@animeshmondal9569 Жыл бұрын
UnderStood Sir🔥🔥 No one can teach like you 😎😎..
@arunimachakraborty1175
@arunimachakraborty1175 3 ай бұрын
This concept was quite complicated and you, as always, made it look so easy. Thanks a lot!
@mihirsaini592
@mihirsaini592 Жыл бұрын
Watched it again after 5 months, can't thank you enough my man
@aparnakanchi
@aparnakanchi Жыл бұрын
Understood . Great to have people like you
@kritikarawat2180
@kritikarawat2180 Жыл бұрын
Impressive man.I understood all concepts told in this video.
@Dontpushyour_luck
@Dontpushyour_luck Жыл бұрын
This was such a nice video. Thank you for teaching all this for free!
@g51661
@g51661 9 ай бұрын
I wish I could hit the like button a thousand times! Thank you, Striver
@vishalbindal5066
@vishalbindal5066 Жыл бұрын
Through this video i am able to understand dsu properly before this i go through various videos and articles but don't get it like after this video thanks bhaiya 🙂
@vishious14
@vishious14 8 ай бұрын
THIS WAS THE BEST EXPLANATION OF DISJOINT SET. OMG !!!!!!!
@rohan8758
@rohan8758 2 ай бұрын
Understood! Such an awesome explanation as always, thank you very much!!🤓
@shubhiagarwal4047
@shubhiagarwal4047 3 ай бұрын
Understood. Striver Sir, this is great to launch dp and graph series. No teacher can do better dry run of the logic like you.
@U2011-n7w
@U2011-n7w Жыл бұрын
your graph series is best on youtube
@utkarshsingh7197
@utkarshsingh7197 Жыл бұрын
Teaching with such a fluency.....Big Fan Sir!!
@sarankumaar6009
@sarankumaar6009 Жыл бұрын
understood. best best best explanation. no one can match this ever
@evilpollination1916
@evilpollination1916 2 ай бұрын
As always amazing video. Understood everything but had to watch twice.
@prashantkumar-oz2in
@prashantkumar-oz2in Жыл бұрын
Now this is quality content.. ❤❤❤
@vijayarana2087
@vijayarana2087 Жыл бұрын
Thanks for creating this video, wonderful explanation
@uavishal777
@uavishal777 Жыл бұрын
Striver bhaiya you are legend for us🔥🔥.i wish that anytime i could meet you.
@mordor2594
@mordor2594 4 ай бұрын
This is the first topic I had to refer some other resource to understand after your video. I love your content but this was the only time I had to go to some other place to understand the concept.
@devchaudhary5002
@devchaudhary5002 Жыл бұрын
Fantastic explanation! thanks a lot my man
@codingid5470
@codingid5470 Жыл бұрын
Wow such clear explanation!
@sunilpanchal1498
@sunilpanchal1498 Жыл бұрын
As always great explanation 🙂
@rohitn6333
@rohitn6333 Жыл бұрын
Thanks for this wonderful explanation sir
@Ballistic_Bytes
@Ballistic_Bytes 7 ай бұрын
Brilliant explanation. Loved it.
@741ibrahim2
@741ibrahim2 Жыл бұрын
Consistency is amazing ✨✨✨✨❤️‍🔥
@shitizgoel5027
@shitizgoel5027 7 ай бұрын
Very nice explanation for union-find algorithm. Thank you very much bhaiya! 🙂
@suryasingh2563
@suryasingh2563 Жыл бұрын
UnderStood bhaiya...thankYOu soo much
@oqant0424
@oqant0424 Жыл бұрын
No one can teach like you!
@SachinKumar-zs6hm
@SachinKumar-zs6hm Ай бұрын
Understood! Thanks a lot Striver.
@augustinradjou3909
@augustinradjou3909 5 ай бұрын
Astonishing work!
@vaishnavimore4860
@vaishnavimore4860 Жыл бұрын
Great explanation🚀 understood!!
@mdsohrabakhtaremam9555
@mdsohrabakhtaremam9555 Жыл бұрын
great explanation help me to understand within few minutes at X2 speed, Instead of searching it over internet and spending lot of time.
@amitp277
@amitp277 Жыл бұрын
What a detailed explanation 👏👏
@sayakghosh5104
@sayakghosh5104 Жыл бұрын
One of the toughest topics in DSA, I've learned till now, DP was much easier. 🙂🙂🙂🙂🙂🙂
@KeshavSingh-yu9jw
@KeshavSingh-yu9jw Жыл бұрын
Maybe you learned about disjoint joint first time today, It all comes down to practice. After some practice you will find it easier(that's the case with me). So lets keep grinding.
@sayakghosh5104
@sayakghosh5104 Жыл бұрын
@@KeshavSingh-yu9jw yes today itself... Let's grind 😊
@krishanpratap3286
@krishanpratap3286 Жыл бұрын
hey it will be easy once u solve some que with this / btw which year ?
@sayakghosh5104
@sayakghosh5104 Жыл бұрын
@@krishanpratap3286 3rd Year. 🙂
@KeshavSingh-yu9jw
@KeshavSingh-yu9jw Жыл бұрын
@@sayakghosh5104 I am in 3rd year as well.
@user-ic7rn1pr8t
@user-ic7rn1pr8t 3 ай бұрын
What an explanation. Hats off🫡
@paragroy5359
@paragroy5359 6 ай бұрын
Thanks a lot for making such videos it is really helpful. Great Content
@reshusingh3558
@reshusingh3558 Жыл бұрын
Understood sir ,thankyou for your support.
@adebisisheriff159
@adebisisheriff159 6 ай бұрын
Amazing content as always!!!!
@shubhiagarwal4047
@shubhiagarwal4047 3 ай бұрын
Not a single dislike shows, a man with no hatred only respect.
@itspurelypassionate
@itspurelypassionate 11 ай бұрын
Thank you! This is is the best explanation of Disjoint Set I've come across. By the way I have a request for one other video. Can you please upload a video explaining leetcode 992 problem. I tried to understand through other channels but I didn't get it. The problem asks us to find the number of subarrays with exact K different integers. Thanks!
@rishabhgupta9846
@rishabhgupta9846 Жыл бұрын
understood ,great explanation
@viraag8667
@viraag8667 Ай бұрын
You made this topic look very easy thanks
@vikashkumarvlogsnitj
@vikashkumarvlogsnitj 10 ай бұрын
impressed , subscribed at first video itself.
@ritwikamahapatra1432
@ritwikamahapatra1432 3 ай бұрын
what an explanation! THANKYOU
@shantipriya370
@shantipriya370 6 ай бұрын
just wow.. superb explanation..
@herculean6748
@herculean6748 Жыл бұрын
lots of love and respect🙌
@adityarai30
@adityarai30 Жыл бұрын
Awesome Explanation♥
@AlokSingh-jw8fr
@AlokSingh-jw8fr Жыл бұрын
Understood everything you taught in video.
@stith_pragya
@stith_pragya 7 ай бұрын
Thank You So Much for this wonderful video...................🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻
@arnavumarkar8259
@arnavumarkar8259 Жыл бұрын
Very well explained. Thanks
@andresfgalvis2010
@andresfgalvis2010 Жыл бұрын
understood, love your videos
@achyutpal6225
@achyutpal6225 Жыл бұрын
Understood very well. Thank you 😄😄😄😄😄😄,
@prasannasippa5962
@prasannasippa5962 Жыл бұрын
understood striver!!! THANK YOU
@virgarg9653
@virgarg9653 Жыл бұрын
Understood Very good bro keep it up .....
@sumerrawat6947
@sumerrawat6947 Жыл бұрын
Amazing explanation
@udaytewary3809
@udaytewary3809 Жыл бұрын
Understood bhaiya 🙏❤️
@vaibhavsharmaiiitu9319
@vaibhavsharmaiiitu9319 Жыл бұрын
Amazing video loved it
@gunahawk6893
@gunahawk6893 Жыл бұрын
thanks man wow what a lecture
@AdityaKumar-be7hx
@AdityaKumar-be7hx Жыл бұрын
understood. And you are awesome!
@abhishekkuntare4640
@abhishekkuntare4640 Жыл бұрын
Understood all the stuffs ❤❤
@rushidesai2836
@rushidesai2836 6 ай бұрын
Very well explained!
@Shubham_gupta18
@Shubham_gupta18 3 ай бұрын
best of all !! kudos to you bro
@shubhrabrahmachari7649
@shubhrabrahmachari7649 2 ай бұрын
you inspired me today . Thank you
@saniyapathan8968
@saniyapathan8968 14 күн бұрын
You are the best🙌
@kr_ankit123
@kr_ankit123 Жыл бұрын
Understood as always :)
@kb-ru4md
@kb-ru4md 2 ай бұрын
Best videos dp and graph🙏
@user-fm2rs1kv2k
@user-fm2rs1kv2k 2 ай бұрын
I find union by rank more intuitive because, without path compression ( i,e, if findPar is not called for any of the nodes ) we can assume rank as the depth of the tree. As Striver mentioned, attaching a smaller depth tree to a larger depth tree is more efficient, and this makes logical sense. In contrast, union by size doesn't provide a clear idea about the tree's depth. When using union by size, we are assuming that a larger size corresponds to a greater depth, which isn't necessarily true in all cases. I would like you to comment your intuition .
@user-lc2lp8zb6l
@user-lc2lp8zb6l 8 ай бұрын
amazingly explained
@beinginnit
@beinginnit Жыл бұрын
Thank You Striver💖💖
@saiyamanand1387
@saiyamanand1387 Жыл бұрын
The content💯🔥
@abhinaviit-bhu7817
@abhinaviit-bhu7817 Жыл бұрын
Understood!🔥
@vigupta-uq1pn
@vigupta-uq1pn 8 ай бұрын
goldmine for DSA🔥🔥
@sobujkhan2602
@sobujkhan2602 7 ай бұрын
this is amazing application really very nice video
@jaswinders2670
@jaswinders2670 Жыл бұрын
very well explained
@cypher7536
@cypher7536 Жыл бұрын
Understood! ❤️
@shashankbhatgs1150
@shashankbhatgs1150 Жыл бұрын
In java, are we updating every node's parent in findUPare function? Bcz after the end of the recursion, we will get the value of last recursive function in the variable ulp, and we are setting parent.set(node, ulp). But it's not backtracking. But in c++ it works. Any solutions? Doubt in this code part: public int findUParent(int node){ if(node == parent.get(node)){ return node; } int ulp = findUParent(parent.get(node)); parent.set(node, ulp); // after recursion ends we are just setting parent of one node, node the entire nodes in that path as mentioned in the video return parent.get(node); }
@Chandraprakash-kx4ic
@Chandraprakash-kx4ic Жыл бұрын
Understood...Thank U striver...
@lingasodanapalli615
@lingasodanapalli615 Жыл бұрын
Understood very well
@Shivanai_h
@Shivanai_h Жыл бұрын
Understood 🙏
@user-tk2vg5jt3l
@user-tk2vg5jt3l Ай бұрын
Thank you bhaiya
@anubhavjasoria4335
@anubhavjasoria4335 Жыл бұрын
Bhai love from odisha ….i have been following you since last year and i feel so confident about the topics that I learned from you ….. “ KEI DINA DEKHA HABA “ - my goal 😂😂
@krishanpratap3286
@krishanpratap3286 Жыл бұрын
which year u at?
@ashishdhal4614
@ashishdhal4614 Жыл бұрын
Bhai kou college
@mihirsaini592
@mihirsaini592 Жыл бұрын
Thank you so much brother
@oqant0424
@oqant0424 Жыл бұрын
UnderStood Sir🔥🔥
@original_gangsta_
@original_gangsta_ Жыл бұрын
Understood 🔥🔥
@coderunner743
@coderunner743 3 ай бұрын
clearly understandable thanks
@AngadSingh97
@AngadSingh97 Жыл бұрын
this was fantastic..
@anandchauhan1868
@anandchauhan1868 10 ай бұрын
Thanks for teaching
@sohammukherjee1392
@sohammukherjee1392 Жыл бұрын
24:16 that finding parent technique via backtracking was nearly similar to print shortest path using Dijkstra's algorithm where we're using that parent array
G-47. Kruskal's Algorithm - Minimum Spanning Tree - C++ and Java
13:11
take U forward
Рет қаралды 154 М.
Finger Heart - Fancy Refill (Inside Out Animation)
00:30
FASH
Рет қаралды 16 МЛН
G-48. Number of Provinces - Disjoint Set
8:03
take U forward
Рет қаралды 64 М.
The moment we stopped understanding AI [AlexNet]
17:38
Welch Labs
Рет қаралды 791 М.
Union Find in 5 minutes - Data Structures & Algorithms
5:46
Potato Coders
Рет қаралды 197 М.
Fastest Way to Learn ANY Programming Language: 80-20 rule
8:24
Sahil & Sarra
Рет қаралды 797 М.
Asking GOOGLE & AMAZON 🚀 Engineers how much money do they make? 🤔
15:42
VICKY KAUSHAL REACTS TO VICKY KAUSHAL MEMES ft. VICKY KAUSHAL
26:42
Tanmay Bhat
Рет қаралды 7 МЛН
The WORST Features in Clash of Clans
14:57
HaVoC Gaming
Рет қаралды 79 М.
I gave 127 interviews. Top 5 Algorithms they asked me.
8:36
Sahil & Sarra
Рет қаралды 628 М.