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

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

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

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

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

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

      ​@@cartube6219 bro both java and c++ are almost same , there are only some minor syntax difference.

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

      Understood

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

      HIndi wala chiye solutions

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

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

    • @praveenkumarp7150
      @praveenkumarp7150 5 дней назад

      Reading his article before this video will also help.

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

    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 Год назад +222

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

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

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

      ​@@yashkagi5399😂

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

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

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

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

  • @KeigoEdits
    @KeigoEdits 4 месяца назад +11

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

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

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

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

  • @AnushkaGupta-x6w
    @AnushkaGupta-x6w Месяц назад +2

    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.

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

  • @mayurbhor2231
    @mayurbhor2231 22 часа назад

    Learning Union By Rank first made Union by Size look easy and intuitive :)

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

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

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

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

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

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

  • @kishorevb8331
    @kishorevb8331 3 месяца назад +1

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

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

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

  • @ashishkumaryadav5252
    @ashishkumaryadav5252 2 года назад +13

    Exceptional content on RUclips. Hats Off

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

    Understood . Great to have people like you

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

    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.

  • @atulkumarsingh6507
    @atulkumarsingh6507 2 дня назад +1

    I watched this video , when it got uploaded (2022) because it was the best at that time. I am watching this video right now (2024) because it is still the best .

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

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

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

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

    your graph series is best on youtube

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

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

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

    Best explanation of DisJointSet you will ever find ❤

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

    Consistency is amazing ✨✨✨✨❤️‍🔥

  • @mayurbhor2231
    @mayurbhor2231 18 часов назад +1

    If you ware wondering what is α(n) is , It is Ackerman's function constant .
    α(1)=1
    𝛼(1012)=4
    𝛼(265536)=5
    The function grows very slowly , and for all practical applications we can consider it as constant

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

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

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

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

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

      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.

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

    Now this is quality content.. ❤❤❤

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

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

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

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

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

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

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

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

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

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

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

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

    UnderStood bhaiya...thankYOu soo much

  • @21BD1A05R
    @21BD1A05R 7 месяцев назад +4

    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 .

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

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

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

    Best video for disjoint set.

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

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

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

    What an explanation.
    Hats off🫡

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

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

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

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

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

    Understood bhaiya 🙏❤️

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

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

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

    Brilliant explanation. Loved it.

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

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

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

    No one can teach like you!

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

    goldmine for DSA🔥🔥

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

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

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

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

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

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

    Understood everything you taught in video.

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

    Thanks for creating this video, wonderful explanation

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

    thanku striver for making such difficult topic so interesting

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

    You are the best🙌

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

    just wow.. superb explanation..

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

    You made this topic look very easy thanks

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

    Thanks for this wonderful explanation sir

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

    Great explanation🚀 understood!!

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

    Understood! Thanks a lot Striver.

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

    damn , you made it look so easy. Thanks Striver

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

    impressed , subscribed at first video itself.

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

    What a detailed explanation 👏👏

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

    Astonishing work!

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

    Best videos dp and graph🙏

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

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

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

    now I am satisfied with the logic and code

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

    Striver Bhaiya op 🥳

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

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

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

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

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

    Amazing video loved it

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

    Very good explanation!

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

    As always great video. Thanks for the awesome content

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

    what an explanation!
    THANKYOU

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

    Understood sir ,thankyou for your support.

  • @garimagupta4208
    @garimagupta4208 6 дней назад

    great video & explanation

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

    ultimate teacher

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

    this is amazing application really very nice video

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

    Understood all the stuffs ❤❤

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

    As always great explanation 🙂

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

    Thank you sir 😊😁

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

    Very well explained!

  • @Shubham_gupta18
    @Shubham_gupta18 8 месяцев назад

    best of all !! kudos to you bro

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

    Wow such clear explanation!

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

    kya video banayi hai boss. Immense respect.

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

    Awesome Explanation♥

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

    lots of love and respect🙌

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

    thanks, understood in 2nd time

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

    Amazing content as always!!!!

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

    Very well explained. Thanks

  • @Stellar_7x
    @Stellar_7x 3 месяца назад +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 ......

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

    you inspired me today . Thank you

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

    Fantastic explanation! thanks a lot my man

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

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

    amazingly explained

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

    amazing explanation.thank u