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

Поделиться
HTML-код
  • Опубликовано: 23 ноя 2024

Комментарии • 419

  • @takeUforward
    @takeUforward  2 года назад +130

    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 6 месяцев назад +1

      HIndi wala chiye solutions

  • @crazyduniya128
    @crazyduniya128 Год назад +209

    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. 🙏😌

  • @valarmorghulis9244
    @valarmorghulis9244 Год назад +118

    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 RUclips. 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.

    • @lavanya_m01
      @lavanya_m01 7 месяцев назад +5

      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 :)

    • @RahulPatel-hr4qe
      @RahulPatel-hr4qe 3 месяца назад +1

      Yes ! Same happend with me in BFS and DFS , Intitally overwhelmed by it , came back after few days and back got it within one chancce

  • @sohailshaik9
    @sohailshaik9 Год назад +213

    Watching this video after watching Abdul Bari sir's video. Both are legends in their own way. Great learning ❤️

    • @yashkagi5399
      @yashkagi5399 Год назад +40

      i used to watch abdul bari's video for sleeping as his voice is very monotonous

    • @vm1662
      @vm1662 Год назад +12

      Same! I just watched Abdul Bari sir's video and now watching Striver. These two are blessings to CS students.

    • @movieskingdom1748
      @movieskingdom1748 Год назад +20

      Khud se bhi karle bhai..sirf video dekhne se kuch ni hota.

    • @shubhamkumar-hx1fb
      @shubhamkumar-hx1fb 8 месяцев назад +1

      ​@@yashkagi5399😂

    • @shubhamkumar-hx1fb
      @shubhamkumar-hx1fb 8 месяцев назад +7

      ​@@movieskingdom1748 khud se questions kiye jate Hain algos ke to videos hi dekhne padte hain 😂

  • @tiyashaghosh9933
    @tiyashaghosh9933 Год назад +16

    The more I see his videos, his work, the more I respect him.

  • @cool.kunalsikri
    @cool.kunalsikri Год назад +59

    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!

  • @arunimachakraborty1175
    @arunimachakraborty1175 7 месяцев назад +3

    This concept was quite complicated and you, as always, made it look so easy. Thanks a lot!

  • @shubhiagarwal4047
    @shubhiagarwal4047 7 месяцев назад +1

    Understood.
    Striver Sir, this is great to launch dp and graph series. No teacher can do better dry run of the logic like you.

  • @AbhinavSingh-rl9zr
    @AbhinavSingh-rl9zr 4 месяца назад +3

    wow literally blown my mind such depth of covering each point with intutition..,.massive amount of practice and hardwork is behind all this..

  • @KeigoEdits
    @KeigoEdits 3 месяца назад +10

    25:29 is such a wholesome reaction of striver lol, like a relative is giving you some money before leaving

  • @SoniaStalance
    @SoniaStalance Год назад +14

    Wow! That was one of the best tutorials I've ever seen.

  • @AnushkaGupta-x6w
    @AnushkaGupta-x6w 6 дней назад

    This was the topic due to which I once got rejected at Google, And Now I can proudly say that this is the topic that is the reason that I got an offer from UBER 🎉🎉.
    THANKS STRIVER❤
    Was a long journey but it was all worth it.

  • @kishorevb8331
    @kishorevb8331 2 месяца назад

    Knowing about the dynamic network connectivity problem really helps out as it is essentially the disjoint set algo is the same as weighted union with path compression

  • @animeshmondal9569
    @animeshmondal9569 2 года назад +23

    UnderStood Sir🔥🔥 No one can teach like you 😎😎..

  • @ashishkumaryadav5252
    @ashishkumaryadav5252 Год назад +13

    Exceptional content on RUclips. Hats Off

  • @jayyanthmalepati7584
    @jayyanthmalepati7584 Год назад +4

    I did understood the class partially not fully but striver's videos have a good content .literally he is my trainer

  • @sanyamjawlia
    @sanyamjawlia Год назад +4

    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.

  • @aparnakanchi
    @aparnakanchi Год назад +4

    Understood . Great to have people like you

  • @AbhishekKumar-td5zu
    @AbhishekKumar-td5zu Месяц назад

    Best explanation of DisJointSet you will ever find ❤

  • @U2011-n7w
    @U2011-n7w Год назад +2

    your graph series is best on youtube

  • @mordor2594
    @mordor2594 8 месяцев назад +1

    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.

  • @741ibrahim2
    @741ibrahim2 2 года назад +9

    Consistency is amazing ✨✨✨✨❤️‍🔥

  • @vishalbindal5066
    @vishalbindal5066 2 года назад +2

    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 🙂

  • @shubhiagarwal4047
    @shubhiagarwal4047 7 месяцев назад

    Not a single dislike shows, a man with no hatred only respect.

  • @21BD1A05R
    @21BD1A05R 6 месяцев назад +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 .

  • @sayakghosh5104
    @sayakghosh5104 2 года назад +19

    One of the toughest topics in DSA, I've learned till now, DP was much easier. 🙂🙂🙂🙂🙂🙂

    • @KeshavSingh-yu9jw
      @KeshavSingh-yu9jw 2 года назад +16

      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 2 года назад +1

      @@KeshavSingh-yu9jw yes today itself... Let's grind 😊

    • @krishanpratap3286
      @krishanpratap3286 2 года назад +1

      hey it will be easy once u solve some que with this /
      btw which year ?

    • @sayakghosh5104
      @sayakghosh5104 2 года назад +1

      @@krishanpratap3286 3rd Year. 🙂

    • @KeshavSingh-yu9jw
      @KeshavSingh-yu9jw 2 года назад +1

      @@sayakghosh5104 I am in 3rd year as well.

  • @kritikarawat2180
    @kritikarawat2180 Год назад +5

    Impressive man.I understood all concepts told in this video.

  • @vishious14
    @vishious14 Год назад +1

    THIS WAS THE BEST EXPLANATION OF DISJOINT SET. OMG !!!!!!!

  • @surabhilakhotia31
    @surabhilakhotia31 13 дней назад

    Thank you sooo much for such detailed and simplified explanation :)

  • @nishigandhagirishdandekar1131
    @nishigandhagirishdandekar1131 2 месяца назад

    Very good explanation! I liked the union by size better than union by rank. It's more intuitive like you said in the video.

  • @anubhavjasoria4335
    @anubhavjasoria4335 2 года назад +3

    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 😂😂

  • @googleit2490
    @googleit2490 Год назад

    Understood :)
    Have to code
    Sep'3, 2023 05:20 pm
    Done at Sep'4,2023 11:30 pm

  • @mihirsaini592
    @mihirsaini592 Год назад +1

    Watched it again after 5 months, can't thank you enough my man

  • @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.

  • @prashantkumar-oz2in
    @prashantkumar-oz2in Год назад +4

    Now this is quality content.. ❤❤❤

  • @sarankumaar6009
    @sarankumaar6009 Год назад +1

    understood. best best best explanation. no one can match this ever

  • @g51661
    @g51661 Год назад +2

    I wish I could hit the like button a thousand times! Thank you, Striver

  • @shitizgoel5027
    @shitizgoel5027 11 месяцев назад

    Very nice explanation for union-find algorithm. Thank you very much bhaiya! 🙂

  • @uavishal777
    @uavishal777 Год назад +2

    Striver bhaiya you are legend for us🔥🔥.i wish that anytime i could meet you.

  • @suryasingh2563
    @suryasingh2563 Год назад +1

    UnderStood bhaiya...thankYOu soo much

  • @ddevarapaga5134
    @ddevarapaga5134 10 дней назад

    Best video for disjoint set.

  • @AbhilashKumar-x2k
    @AbhilashKumar-x2k 7 месяцев назад +1

    What an explanation.
    Hats off🫡

  • @AlokSingh-jw8fr
    @AlokSingh-jw8fr 2 года назад +1

    Understood everything you taught in video.

  • @Ballistic_Bytes
    @Ballistic_Bytes 11 месяцев назад +1

    Brilliant explanation. Loved it.

  • @Malmo308
    @Malmo308 2 месяца назад

    Very nice video! Everything was explained clearly. Thank you very much!

  • @Stellar_7x
    @Stellar_7x 2 месяца назад +1

    In our university they only taught algorithms of krushkals and prims and dijkstras and in psudo code they just wrote union and gave 0 knowledge about union ...... THEY THINK THAT WE'RE THE GENIUS THAT WE FIGURE IT OUT ON OUR OWN LOL ! , aap knowledge to dete hi ho sath mai degree bhi dene lago ......

  • @utkarshsingh7197
    @utkarshsingh7197 Год назад

    Teaching with such a fluency.....Big Fan Sir!!

  • @cinime
    @cinime 2 года назад +5

    Understood! Such an awesome explanation as always, thank you very much!!

  • @viraag8667
    @viraag8667 5 месяцев назад

    You made this topic look very easy thanks

  • @raghavmanish24
    @raghavmanish24 2 месяца назад

    thanku striver for making such difficult topic so interesting

  • @evilpollination1916
    @evilpollination1916 6 месяцев назад

    As always amazing video. Understood everything but had to watch twice.

  • @oqant0424
    @oqant0424 2 года назад

    No one can teach like you!

  • @sohammukherjee1392
    @sohammukherjee1392 Год назад +8

    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

  • @vijayarana2087
    @vijayarana2087 Год назад +2

    Thanks for creating this video, wonderful explanation

  • @rohitn6333
    @rohitn6333 Год назад +2

    Thanks for this wonderful explanation sir

  • @itspurelypassionate
    @itspurelypassionate Год назад +1

    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!

  • @augustinradjou3909
    @augustinradjou3909 9 месяцев назад

    Astonishing work!

  • @Dontpushyour_luck
    @Dontpushyour_luck Год назад +1

    This was such a nice video. Thank you for teaching all this for free!

  • @kb-ru4md
    @kb-ru4md 6 месяцев назад +1

    Best videos dp and graph🙏

  • @shantipriya370
    @shantipriya370 10 месяцев назад

    just wow.. superb explanation..

  • @vigupta-uq1pn
    @vigupta-uq1pn Год назад

    goldmine for DSA🔥🔥

  • @vaishnavimore4860
    @vaishnavimore4860 Год назад +1

    Great explanation🚀 understood!!

  • @shauryatomer1058
    @shauryatomer1058 3 месяца назад

    As always great video. Thanks for the awesome content

  • @saniyapathan8968
    @saniyapathan8968 4 месяца назад +1

    You are the best🙌

  • @nazibur175
    @nazibur175 Месяц назад

    Very good explanation!

  • @rishabh7215
    @rishabh7215 4 месяца назад

    Finding union by size to be more intuitive so I guess I'll follow that over union by rank

  • @AyushEditz-hs6pf
    @AyushEditz-hs6pf 2 месяца назад

    damn , you made it look so easy. Thanks Striver

  • @paragroy5359
    @paragroy5359 10 месяцев назад

    Thanks a lot for making such videos it is really helpful.
    Great Content

  • @Qwerty-yi3js
    @Qwerty-yi3js 3 месяца назад

    I think I need to watch it again and again...to get a hold of it...

  • @TarunKumarSaraswat
    @TarunKumarSaraswat Месяц назад

    thanks, understood in 2nd time

  • @achyutpal6225
    @achyutpal6225 Год назад

    Understood very well.
    Thank you 😄😄😄😄😄😄,

  • @sobujkhan2602
    @sobujkhan2602 11 месяцев назад

    this is amazing application really very nice video

  • @vikashkumarvlogsnitj
    @vikashkumarvlogsnitj Год назад

    impressed , subscribed at first video itself.

  • @reshusingh3558
    @reshusingh3558 Год назад

    Understood sir ,thankyou for your support.

  • @amitp277
    @amitp277 Год назад

    What a detailed explanation 👏👏

  • @chirag.3082
    @chirag.3082 5 месяцев назад

    though he expertly explained both by and by size i feel like he should have led with union by size, its a bit simpler and more intuitive especially for beginners

  • @m.afnan2018
    @m.afnan2018 Год назад

    Understood, But I am going to try it by myself to get more clear picture.

  • @tanmay07777
    @tanmay07777 3 месяца назад

    kya video banayi hai boss. Immense respect.

  • @udaytewary3809
    @udaytewary3809 Год назад

    Understood bhaiya 🙏❤️

  • @SachinKumar-zs6hm
    @SachinKumar-zs6hm 5 месяцев назад

    Understood! Thanks a lot Striver.

  • @praneethaimandi1790
    @praneethaimandi1790 3 месяца назад

    amazing explanation.thank u

  • @ritwikamahapatra1432
    @ritwikamahapatra1432 7 месяцев назад

    what an explanation!
    THANKYOU

  • @arnavumarkar8259
    @arnavumarkar8259 Год назад

    Very well explained. Thanks

  • @ebukaegbunam8716
    @ebukaegbunam8716 10 месяцев назад

    ultimate teacher

  • @shubhrabrahmachari7649
    @shubhrabrahmachari7649 6 месяцев назад

    you inspired me today . Thank you

  • @abhishekkuntare4640
    @abhishekkuntare4640 2 года назад

    Understood all the stuffs ❤❤

  • @vaibhavsharmaiiitu9319
    @vaibhavsharmaiiitu9319 Год назад +1

    Amazing video loved it

  • @virgarg9653
    @virgarg9653 Год назад

    Understood Very good bro keep it up .....

  • @anandchauhan1868
    @anandchauhan1868 Год назад

    Thanks for teaching

  • @rushidesai2836
    @rushidesai2836 10 месяцев назад

    Very well explained!

  • @stith_pragya
    @stith_pragya 11 месяцев назад +1

    Thank You So Much for this wonderful video...................🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻

  • @sanchitsrivastav453
    @sanchitsrivastav453 Год назад

    now I am satisfied with the logic and code

  • @armaan4529
    @armaan4529 27 дней назад

    watched 2nd time and understood everything

  • @avocode1487
    @avocode1487 2 года назад +1

    For me striver has become youtube n google both, bcoz if I want to learn any concept whether it be ez or tough I come to TUF.

  • @UECAshutoshKumar
    @UECAshutoshKumar 11 месяцев назад +1

    Thank you sir 😊😁

  • @AnamikaMishra-c7b
    @AnamikaMishra-c7b Год назад

    amazingly explained

  • @herculean6748
    @herculean6748 Год назад

    lots of love and respect🙌

  • @codingid5470
    @codingid5470 2 года назад

    Wow such clear explanation!

  • @amanbhadani8840
    @amanbhadani8840 2 года назад

    Striver Bhaiya op 🥳

  • @kasamadhu3509
    @kasamadhu3509 Год назад +2

    union by rank , union by size are optimal solutions to union.