Disjoint Set | UNION and FIND

แชร์
ฝัง
  • เผยแพร่เมื่อ 15 ก.ค. 2020
  • This video explains the basics of disjoint set data structure from scratch.I have explained all about disjoint set data structure in a simple and easy way to clear your basic understanding on the disjoint set data structure.I have taken intuitive examples and an intuitive algorithm to explain this data structure.I have explained the parent child relationship in a disjoint set by using tree structure for better understanding.I have explained the CODE implementation in the description below.CODE LINK is present below as usual. If you find any difficulty or have any query then do COMMENT below. PLEASE help our channel by SUBSCRIBING and LIKE our video if you found it helpful...CYA :)
    ========================================================================
    INSTAGRAM : / surya.pratap.k
    SUPPORT OUR WORK: / techdose
    LinkedIn: / surya-pratap-kahar-47b...
    WEBSITE: techdose.co.in/
    TELEGRAM Channel LINK: t.me/codewithTECHDOSE
    TELEGRAM Group LINK: t.me/joinchat/SRVOIxWR4sRIVv5...
    =======================================================================
    CODE LINK: gist.github.com/SuryaPratapK/...

ความคิดเห็น • 266

  • @yooos3
    @yooos3 3 ปีที่แล้ว +20

    Clear and concise! It's funny the moment I saw how you created the array, I understood and I was able to code it as well! This video helped me clearly visualize how Union and Find works! Thank you!

  • @AkashPawar-qv4ps
    @AkashPawar-qv4ps 2 ปีที่แล้ว +2

    literally this is one of the clear and conceptual explanation of union find I have ever came across.

  • @naman_goyal
    @naman_goyal 4 ปีที่แล้ว +24

    sir ur video content is very good.. in every competition i always say a time..han ye to techdose sir ki video mein dekha tha yaha yahi concept legega..thanku for this awesome concept

    • @techdose4u
      @techdose4u  4 ปีที่แล้ว +1

      Thanks bro....it means a lot :)

  • @safalyaghoshroy2405
    @safalyaghoshroy2405 4 ปีที่แล้ว +59

    Pls don't discontinue graph series🙏🙏🙏

  • @rummanchowdhury3807
    @rummanchowdhury3807 ปีที่แล้ว +1

    Fantastic explanation! It's great to hear you explain your thought process as you unfold the steps one by one

  • @sakshigupta7616
    @sakshigupta7616 3 ปีที่แล้ว +11

    Awesome explanations! I am literally heading to your explanation for every topic I learn now and then! Keep goin'

  • @smmahadibhuiyan4437
    @smmahadibhuiyan4437 ปีที่แล้ว +2

    this channel, this video is BEST. this topic is perfectly descrived here. None of video on this topic is not good as it in TH-cam . So RECOMMENDED for ALL.

    • @techdose4u
      @techdose4u  ปีที่แล้ว

      Thanks for your appreciation

  • @MilindGupta
    @MilindGupta 2 ปีที่แล้ว +3

    Man you explained this so beautifully felt it's so easy now 😭🙏

  • @adityaojha2701
    @adityaojha2701 2 ปีที่แล้ว +2

    I am following this channel since it was having 30K subscriber. You have helped me a lot understanding DSA. Thanks a lot for such great explanations.

  • @ashwinram9081
    @ashwinram9081 4 ปีที่แล้ว +5

    Thanks for making this graph series. Your are always inspired to learn

  • @tranvuong3273
    @tranvuong3273 6 หลายเดือนก่อน

    it is very helpful. I hope this channel would have more people to watch because it deserves it. thanks a lot!

  • @shaswatdas6553
    @shaswatdas6553 4 ปีที่แล้ว +6

    a few months left before the channel explodes, cuz the content is top notch!

    • @techdose4u
      @techdose4u  4 ปีที่แล้ว +1

      Thanks for appreciation :)

    • @shaswatdas6553
      @shaswatdas6553 4 ปีที่แล้ว

      i commented on cycle detection in directed graph. Can you clear the doubt?
      code-gist.github.com/SuryaPratapK/e84cf8624da8a690f11d5ce31745b808
      video-th-cam.com/video/0dJmTuMrUZM/w-d-xo.html
      comment-
      Sir in this function need correction i guess...
      bool isCyclic_util(vector adj[], vector visited, int curr)
      {
      if(visited[curr]==true)
      return true;
      visited[curr] = true;
      bool FLAG = false;
      for(int i=0;i

  • @jewelchowdhury9752
    @jewelchowdhury9752 ปีที่แล้ว

    That is a great explanation of DSU..... I am deeply appreciative of your efforts and wanted to extend a heartfelt thank you.

  • @rajatbudania6181
    @rajatbudania6181 4 ปีที่แล้ว +8

    Brilliant as usual :)
    Sir, can u plz make videos on OS or DBMS totally focusing placements!! Will be a huge help :)

    • @techdose4u
      @techdose4u  4 ปีที่แล้ว +7

      I will give the important topics to study soon for theory preparation.

  • @princeakhil208
    @princeakhil208 4 ปีที่แล้ว +4

    Tech dose is back 😁 maza aa gaya

  • @MJ-ur9tc
    @MJ-ur9tc 3 ปีที่แล้ว +2

    Superb. Very detailed explanation. Please keep up the good work. It made me subscribe to your channel. Now, I’ll definitely watch all of your videos. Thanks a ton for the excellent content.

  • @manojg4451
    @manojg4451 3 ปีที่แล้ว +5

    Finally, a tutorial that makes sense 🙏🙏🙏

  • @shyammakwana3770
    @shyammakwana3770 3 ปีที่แล้ว +2

    Sir again very very deeply respect to you and your all Playlist on diff topics it is very useful for us. Never stop to make videos 🙏🙏🙏🙏🙏

  • @PradeepKumarIIITD
    @PradeepKumarIIITD 3 ปีที่แล้ว +1

    I like video first, then start watching it... :)

  • @K_EC_AushoRoup
    @K_EC_AushoRoup 3 ปีที่แล้ว +2

    Thanks!! It helped. I was struggling a lot in this topic.

  • @debaratighatak2211
    @debaratighatak2211 3 ปีที่แล้ว +4

    Thank you so much sir for giving such an amazing explanation❤️🙏

  • @iamakifislam
    @iamakifislam 3 ปีที่แล้ว +4

    Your tutorial is the best in the internet. ❤️

  • @mainakmondal8691
    @mainakmondal8691 3 ปีที่แล้ว +1

    Can't be better explanation than this one..thank you sir.

  • @anmoljain5910
    @anmoljain5910 4 ปีที่แล้ว +2

    seen many videos on this topic. This one explains the concept best. Please make Union by rank and Path Compression video soon.

  • @sudhanshukumar1558
    @sudhanshukumar1558 4 ปีที่แล้ว +6

    I got my binge watching content. Thanks 😊

    • @techdose4u
      @techdose4u  4 ปีที่แล้ว +1

      Awesome :D

    • @sudhanshukumar1558
      @sudhanshukumar1558 4 ปีที่แล้ว +1

      @@techdose4u done with watching it, great explanation 👍

    • @techdose4u
      @techdose4u  4 ปีที่แล้ว

      Thanks

  • @beingvoid3246
    @beingvoid3246 3 ปีที่แล้ว +8

    i have a doubt , at 26:06 , we have already found the absolute parent of x,y so why are we again finding the absolute parent of Fromp and Top as we already did it in the iscyclic function ?

    • @LUKFUNTV
      @LUKFUNTV 2 ปีที่แล้ว

      Redundancy may happen sometimes.... Just ignore those 2 lines.. As we have already found the parents..

    • @namansharma5128
      @namansharma5128 2 ปีที่แล้ว

      was finding this doubt only 😅😅

  • @ss-xh3hf
    @ss-xh3hf 3 ปีที่แล้ว +4

    Loving it please make a similar series on backtracking

    • @techdose4u
      @techdose4u  3 ปีที่แล้ว +2

      It will come. Stay tuned :)

  • @bhuvanchandrajoshi9138
    @bhuvanchandrajoshi9138 3 ปีที่แล้ว +3

    I think you are underrated like imdb movies

    • @techdose4u
      @techdose4u  3 ปีที่แล้ว

      Hope I get good reach soon :)

  • @divyanshdixit4944
    @divyanshdixit4944 4 ปีที่แล้ว +3

    Thanks for the amazing video. Please add Linux video that you promised, whenever you get time. Once again keep up the good work.

    • @techdose4u
      @techdose4u  4 ปีที่แล้ว +2

      Linux video for theory syllabus?

    • @divyanshdixit4944
      @divyanshdixit4944 4 ปีที่แล้ว +1

      @@techdose4u Yes sir, list of important topics and commands of Linux for interview

  • @PoojaGupta-ry3oj
    @PoojaGupta-ry3oj 4 ปีที่แล้ว +8

    can you also make video on backtracking..till now I haven't found any good resource for it. ur videos are so good.. it gives grasp on the concept in one go..

    • @techdose4u
      @techdose4u  4 ปีที่แล้ว +3

      I will start that series later along with dynamic programming.

    • @PoojaGupta-ry3oj
      @PoojaGupta-ry3oj 4 ปีที่แล้ว

      @@techdose4u thank u.. wish to see soon :)

  • @acousticIndie
    @acousticIndie 3 ปีที่แล้ว +1

    Thank you so much, means a lot! Keep it up!

  • @yulianloaiza
    @yulianloaiza ปีที่แล้ว +1

    You explain so well! Thank you very much :)

  • @frunked
    @frunked 3 ปีที่แล้ว +2

    helped me on my exam. much love from university of illinois 👍

    • @techdose4u
      @techdose4u  3 ปีที่แล้ว +1

      Thanks Matt ❤️

  • @prajwalmp8583
    @prajwalmp8583 3 ปีที่แล้ว +1

    This gave me a clear picture... thanks a lot😀

  • @jigarsingh600
    @jigarsingh600 4 ปีที่แล้ว +1

    Very well explained. Please keep making such informative videos.

  • @kavishamanchanda7141
    @kavishamanchanda7141 3 ปีที่แล้ว

    Can you please tell me in the union function why did you add absolute parents in the dfus array and why not the original fromP and toP

  • @aayush5474
    @aayush5474 4 ปีที่แล้ว +2

    Best explanation bro! Thank you

  • @Faiazur_Rahman_Bhuiya_-
    @Faiazur_Rahman_Bhuiya_- 3 ปีที่แล้ว

    I love this guy.

  • @deepakprajapati5064
    @deepakprajapati5064 3 ปีที่แล้ว +1

    Explaining complex problem in a simple way 🔥🔥

  • @vishaltk3013
    @vishaltk3013 3 ปีที่แล้ว

    which software are you using to draw and demo using the slides?

  • @sarthakbhatia7888
    @sarthakbhatia7888 3 ปีที่แล้ว +1

    Thankyou..:)...This series is great

  • @regularsizedpanda
    @regularsizedpanda 4 ปีที่แล้ว +1

    This is pure gold.

  • @SUJOYPAULJOBS
    @SUJOYPAULJOBS 3 ปีที่แล้ว +1

    khub bhalo bojalen sir nice teacher

  • @shubhamkhurana7545
    @shubhamkhurana7545 4 ปีที่แล้ว +2

    That was really something new!!

  • @rudreshajgaonkar
    @rudreshajgaonkar 2 ปีที่แล้ว

    If the nodes are 0,1,2,3 then using a Array is fine to keep track of parent child relationship. But the moment we have vertices as 3,4,5,6 isnt it good to keep a map in that place?

  • @nikitamandlik6067
    @nikitamandlik6067 2 ปีที่แล้ว

    Thanks for the explanation :) May I know which tool is used for explaining the problems

  • @frankdaniel3506
    @frankdaniel3506 2 ปีที่แล้ว +1

    Which Software are you using for explanation?Thanks-Frank

  • @shagunlamba6481
    @shagunlamba6481 3 ปีที่แล้ว +2

    amazing explaination, thank you :)

  • @prabhatchanchal
    @prabhatchanchal 4 ปีที่แล้ว +2

    Thanks sir.
    please make all of DSU lecture in series from now. like kruskal and DSU on grid.

    • @techdose4u
      @techdose4u  4 ปีที่แล้ว +2

      I will give optimized approach explanations and later I will add more complex algos. Fir now, target is to cover for interview.

  • @abhishekkeer1520
    @abhishekkeer1520 4 ปีที่แล้ว +11

    what is need of again call find function in union_op because we already get absolute root of both element ?

    • @shushantgaur9420
      @shushantgaur9420 3 ปีที่แล้ว +3

      Exactly... Line 15 and 16 are doing same thing as line 24 25, right?

    • @techdose4u
      @techdose4u  3 ปีที่แล้ว +4

      You can skip that. I have commented it in the next video.

    • @shushantgaur9420
      @shushantgaur9420 3 ปีที่แล้ว +3

      @@techdose4u yes I saw that afterwards but I forgot to remove this comment😅. By the way that's one hell of an explaination..... I don't think I'm gonna forget it anytime soon.... Thanks 😊.

    • @techdose4u
      @techdose4u  3 ปีที่แล้ว +4

      @@shushantgaur9420 You better not forget it :P

    • @shushantgaur9420
      @shushantgaur9420 3 ปีที่แล้ว

      @@techdose4u never😁

  • @dochimekashiariri7610
    @dochimekashiariri7610 2 ปีที่แล้ว

    in the union function, there is no need to write the find function right?? cause we are already sending the absolute parent to it.

  • @joydeepbhattacharjee5305
    @joydeepbhattacharjee5305 3 ปีที่แล้ว +1

    great video...best channel for DSA

  • @Leetforces_com
    @Leetforces_com 4 ปีที่แล้ว +1

    Wow!! too easy explanation ❤️

  • @kunalsoni7681
    @kunalsoni7681 4 ปีที่แล้ว +1

    Very helpful video 😊😇..
    Thank you sir

  • @shalini-j-2r
    @shalini-j-2r 3 ปีที่แล้ว +2

    I do not think , we need to use find again in union method as we have already find the parent of both elements.
    Is there any specific reason?

    • @techdose4u
      @techdose4u  3 ปีที่แล้ว

      No specific reason. Try to exclude it. I had exluded it in my next lecture.

  • @mdimranhosen6674
    @mdimranhosen6674 2 ปีที่แล้ว

    Brilliant as usual.

  • @rajmani4486
    @rajmani4486 3 ปีที่แล้ว +1

    amazing explanation...

  • @siddharthasharma9316
    @siddharthasharma9316 4 ปีที่แล้ว +1

    Going to watch this tonight.....pakka

  • @nishithramanuj509
    @nishithramanuj509 2 ปีที่แล้ว +1

    Very good explanation sir

  • @jameskennedy674
    @jameskennedy674 2 ปีที่แล้ว

    Pretty good Explanation.

  • @ayushgoel9584
    @ayushgoel9584 4 ปีที่แล้ว +3

    Hi bro, I checked your content , it is awesome, but it would be great if you can arrange all your videos in difficulty level and topic wise level in your playlist.Many videos are missing in playlist or repeating in playlist. Please try to create proper sequence of all your videos, so that it would be helpful for everyone

    • @techdose4u
      @techdose4u  4 ปีที่แล้ว

      Thanks. I am trying to do that

    • @ayushgoel9584
      @ayushgoel9584 4 ปีที่แล้ว +1

      @@techdose4u yeah, I have recommended your channel to many of my friends, some of them are begineers, and they get lost from where to start watching your videos, thats why

    • @techdose4u
      @techdose4u  4 ปีที่แล้ว

      Okay....I understand. I will arrange them. Actually I haven't covered many basic topics like time and space complexity, hash, heap etc properly. There are missing topics as well. So, as soon as I finish graph algorithms, I will cover the basics and clear them so that I will have everything required for placement purpose :)

  • @shreelakshmi6890
    @shreelakshmi6890 3 ปีที่แล้ว +1

    Great video again!!👌

  • @yihongliu3850
    @yihongliu3850 3 ปีที่แล้ว +4

    very nice content as usual sir! just have one small question -- at line 24& line 25, we already find the absolute parent of the subset.. and in the union_op function (line 13-18) we find that again.. is it because we want to keep the complete functionality of union_op here?

    • @techdose4u
      @techdose4u  3 ปีที่แล้ว +1

      I think you can skip that. I may have forgot to not comment those lines

    • @yihongliu3850
      @yihongliu3850 3 ปีที่แล้ว +1

      @@techdose4u haha thanks!!

  • @nehamahendrasingh4478
    @nehamahendrasingh4478 4 ปีที่แล้ว +1

    Hi :)Thank you so much for the video .. Could you please make a video on time and space complexity .Thank you

    • @techdose4u
      @techdose4u  4 ปีที่แล้ว

      Do you mean time and space complexity series videos?

    • @nehamahendrasingh4478
      @nehamahendrasingh4478 4 ปีที่แล้ว

      TECH DOSE yes please, Atleast one video explaining how to calculate time and space complexity

  • @shanmukhavarma3361
    @shanmukhavarma3361 4 ปีที่แล้ว +1

    Tq bro I could solve dsu problems in codeforces

    • @techdose4u
      @techdose4u  4 ปีที่แล้ว +2

      Nice :) this was just basic. I will soon make optimized dsu as well :)

  • @amrkhalid275
    @amrkhalid275 7 หลายเดือนก่อน

    thank u sir very helpful
    ...

  • @sallaklamhayyen9876
    @sallaklamhayyen9876 หลายเดือนก่อน

    great explanation
    thank you so much🥰🥰🥰

  • @AltafHussain-on2oe
    @AltafHussain-on2oe 3 ปีที่แล้ว +1

    Thanks from the Heart 💖

  • @bespoyasov
    @bespoyasov 2 ปีที่แล้ว +1

    Awesome! Thank you!

  • @impatientgaming9868
    @impatientgaming9868 7 หลายเดือนก่อน

    Really Helpful!

  • @yasharma2301
    @yasharma2301 3 ปีที่แล้ว +1

    Perfect explanation!

  • @rishijha9860
    @rishijha9860 4 ปีที่แล้ว +1

    Very well explained!!!

  • @Sky-nt1hy
    @Sky-nt1hy 3 ปีที่แล้ว +1

    Hi !!
    I have a question regarding the code.
    Aren't line 15,16 unnecessary? Since when you pass fromP and toP to union_op function, they're already the absolute roots so it seems there's no need to find the absolute roots when they are already.
    Thank you!

    • @techdose4u
      @techdose4u  3 ปีที่แล้ว +1

      Yea seems so. You can comment that.

    • @Sky-nt1hy
      @Sky-nt1hy 3 ปีที่แล้ว +1

      @@techdose4u That was almost an instantaneous reply. Thank you!

    • @techdose4u
      @techdose4u  3 ปีที่แล้ว

      Welcome :)

  • @david.breyer
    @david.breyer 2 ปีที่แล้ว

    Sir, why does 17:35 connect 0 to 3 in the image but the array is 1 to 3 ?
    It should be like:
    0 -- 1
    / |
    3 -- 2

  • @niteshkhetan9757
    @niteshkhetan9757 3 ปีที่แล้ว

    Sir in the first tree which looks like linked list, why is 2 the parent of 3, instead 3 is the parent of 2... Right? Am I missing something?

  • @jayantaghosh7678
    @jayantaghosh7678 3 หลายเดือนก่อน

    awesome explanation

  • @himanshuchhikara4918
    @himanshuchhikara4918 4 ปีที่แล้ว +1

    Welcome back sir

  • @pulkitmoolchandani6049
    @pulkitmoolchandani6049 4 ปีที่แล้ว +1

    great video :)

  • @dovyraj1272
    @dovyraj1272 3 ปีที่แล้ว +2

    can v use graph coloring and dfs for representing same set, that would b every easy

    • @techdose4u
      @techdose4u  3 ปีที่แล้ว +1

      Disjoint set will be easier and much more efficient. Try to learn disjoint set and you will know the simplicity of this DS.

  • @VarsneyaSrinivas
    @VarsneyaSrinivas 3 ปีที่แล้ว +1

    Pls don't ever stop.

  • @dharmeshupadhyay4778
    @dharmeshupadhyay4778 3 ปีที่แล้ว +1

    sir i love your videos , you are an excellent teacher , and sir your voice is fabulous
    sir plz also make MOTIVETIONAL VIDEOS ,i will be first to watch it
    sir i thing in union() operation their is no need to call find() bcz we already have parents ,?????????????????????

    • @techdose4u
      @techdose4u  3 ปีที่แล้ว

      Try it out. Maybe it's true :)

  • @mahipalsingh-yo4jt
    @mahipalsingh-yo4jt 3 ปีที่แล้ว +1

    great explanation sir !!!!!!!!!!!!!!!!!!!!

  • @shubhamrn1885
    @shubhamrn1885 3 ปีที่แล้ว +1

    sir where did you learn all this? In mumbai university there are no such topics taught to us. Your content is really high value. pls reply.
    thank you

  • @acxd
    @acxd 3 ปีที่แล้ว +1

    Amazing amazing !!

    • @techdose4u
      @techdose4u  3 ปีที่แล้ว

      Thanks thanks :D

  • @Mandeepsingh-jo5cf
    @Mandeepsingh-jo5cf 3 ปีที่แล้ว +1

    Thanks graph specialist.

  • @kumartejaswi712
    @kumartejaswi712 3 ปีที่แล้ว

    bhai yaar😍

  • @ravikumarkamble6403
    @ravikumarkamble6403 3 ปีที่แล้ว +1

    hey Tech dose your video are amazing can u plz provide these ppt type explanation screenshots it will more helpful for the revision after seeing the video.

    • @techdose4u
      @techdose4u  3 ปีที่แล้ว

      Thanks. I am putting them on our website.

    • @ravikumarkamble6403
      @ravikumarkamble6403 3 ปีที่แล้ว

      @@techdose4u nice to see.

  • @ridoychandradey8337
    @ridoychandradey8337 2 ปีที่แล้ว

    Thank you very much.

  • @Aman-jc7pu
    @Aman-jc7pu 2 ปีที่แล้ว

    I think there is no need to again find the absolute parent in union function. By the way Great Explanation.

  • @psthakur1199
    @psthakur1199 4 ปีที่แล้ว +1

    Please could you upload a few more good Backtracking Problems in Recursion playlist.

  • @canopus74
    @canopus74 3 ปีที่แล้ว +1

    Sir, Which one is best to the detect cycle in Unordered graph?
    1). Colouring of a graph.
    2). DS data structure.

    • @techdose4u
      @techdose4u  3 ปีที่แล้ว +1

      Anyone which you find easier to implement :)

    • @canopus74
      @canopus74 3 ปีที่แล้ว

      @@techdose4u oky.... thanks

  • @lancelotdsouza4705
    @lancelotdsouza4705 2 ปีที่แล้ว

    beautifully explained

  • @anantpawar782
    @anantpawar782 2 ปีที่แล้ว

    why u find absolute parent again in union_op function. We already find out abs parent in isCylic func.

  • @musheer.ahmed.0
    @musheer.ahmed.0 2 ปีที่แล้ว

    Thanks you very much😁

  • @khaledov7305
    @khaledov7305 3 หลายเดือนก่อน

    Thanks a lot .

  • @dhanichauhan3010
    @dhanichauhan3010 3 ปีที่แล้ว +1

    sir very nice speaking skills

  • @sagarlandge3271
    @sagarlandge3271 3 ปีที่แล้ว

    Best 26.42 minutes of my life

  • @VarunKaushal-zx9zq
    @VarunKaushal-zx9zq ปีที่แล้ว

    Amazing sir

  • @gauravchaudhari3843
    @gauravchaudhari3843 3 ปีที่แล้ว +1

    nice please please zoom in while explaing code so mobile devices can understand written code as well sublime has simple ctrl + to zoom in

    • @techdose4u
      @techdose4u  3 ปีที่แล้ว

      Right 😅 I will use larger fonts instead.

  • @bmabdullaalmahmud5386
    @bmabdullaalmahmud5386 2 ปีที่แล้ว

    You said by using DS we can detect cycle for an undirected graph.. But if there is only one edge in a bidirected graph there is a cycle.. That means it always give true result detecting cycle using ds for undirected graph. So, detecting cycle have no means here..Isn't?
    Please Reply ASAP.