Тёмный
No video :(

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

take U forward
Подписаться 642 тыс.
Просмотров 253 тыс.
50% 1

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.geeksforge...
Java Code Snippet of DS: ide.geeksforge...
C++/Java/Codes and Notes Link: takeuforward.o...
DP Series: • Striver's Dynamic Prog...
SDE Sheet: takeuforward.o...
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.geeks...
Code "takeuforward" for 20% off on sys-design: get.interviewr...?_aff=takeuforward
Crypto, I use the Wazirx app: wazirx.com/inv...
Take 750 rs free Amazon Stock from me: indmoney.oneli...
Earn 100 rs by making a Grow Account for investing: app.groww.in/v...
Linkedin/Instagram/Telegram: linktr.ee/take...
---------------------------------------------------------------------------------------------------------------------------

Опубликовано:

 

21 окт 2022

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 370   
@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. 🙏😌
@valarmorghulis9244
@valarmorghulis9244 Год назад
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 RU-vid. 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 4 месяца назад
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 дня назад
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 Год назад
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 Год назад
Same! I just watched Abdul Bari sir's video and now watching Striver. These two are blessings to CS students.
@movieskingdom1748
@movieskingdom1748 11 месяцев назад
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 😂
@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 Год назад
systumm!
@rollercoaster9719
@rollercoaster9719 11 месяцев назад
now the biggest qn is, how the hell did u get a job if u never did coding in college
@shibainu7500
@shibainu7500 5 месяцев назад
@@rollercoaster9719 Aisa hi hota tha
@AbhinavSingh-rl9zr
@AbhinavSingh-rl9zr Месяц назад
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.
@animeshmondal9569
@animeshmondal9569 Год назад
UnderStood Sir🔥🔥 No one can teach like you 😎😎..
@SoniaStalance
@SoniaStalance Год назад
Wow! That was one of the best tutorials I've ever seen.
@ashishkumaryadav5252
@ashishkumaryadav5252 Год назад
Exceptional content on RU-vid. Hats Off
@KeigoEdits
@KeigoEdits 5 дней назад
25:29 is such a wholesome reaction of striver lol, like a relative is giving you some money before leaving
@jayyanthmalepati7584
@jayyanthmalepati7584 Год назад
I did understood the class partially not fully but striver's videos have a good content .literally he is my trainer
@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.
@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.
@arunimachakraborty1175
@arunimachakraborty1175 4 месяца назад
This concept was quite complicated and you, as always, made it look so easy. Thanks a lot!
@aparnakanchi
@aparnakanchi Год назад
Understood . Great to have people like you
@shubhiagarwal4047
@shubhiagarwal4047 4 месяца назад
Understood. Striver Sir, this is great to launch dp and graph series. No teacher can do better dry run of the logic like you.
@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 .
@741ibrahim2
@741ibrahim2 Год назад
Consistency is amazing ✨✨✨✨❤️‍🔥
@googleit2490
@googleit2490 11 месяцев назад
Understood :) Have to code Sep'3, 2023 05:20 pm Done at Sep'4,2023 11:30 pm
@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
@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 🙂
@kritikarawat2180
@kritikarawat2180 Год назад
Impressive man.I understood all concepts told in this video.
@U2011-n7w
@U2011-n7w Год назад
your graph series is best on youtube
@vishious14
@vishious14 9 месяцев назад
THIS WAS THE BEST EXPLANATION OF DISJOINT SET. OMG !!!!!!!
@g51661
@g51661 10 месяцев назад
I wish I could hit the like button a thousand times! Thank you, Striver
@mihirsaini592
@mihirsaini592 Год назад
Watched it again after 5 months, can't thank you enough my man
@prashantkumar-oz2in
@prashantkumar-oz2in Год назад
Now this is quality content.. ❤❤❤
@cinime
@cinime Год назад
Understood! Such an awesome explanation as always, thank you very much!!
@uavishal777
@uavishal777 Год назад
Striver bhaiya you are legend for us🔥🔥.i wish that anytime i could meet you.
@shubhiagarwal4047
@shubhiagarwal4047 4 месяца назад
Not a single dislike shows, a man with no hatred only respect.
@user-ic7rn1pr8t
@user-ic7rn1pr8t 3 месяца назад
What an explanation. Hats off🫡
@mordor2594
@mordor2594 5 месяцев назад
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.
@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.
@sarankumaar6009
@sarankumaar6009 Год назад
understood. best best best explanation. no one can match this ever
@evilpollination1916
@evilpollination1916 3 месяца назад
As always amazing video. Understood everything but had to watch twice.
@suryasingh2563
@suryasingh2563 Год назад
UnderStood bhaiya...thankYOu soo much
@rohan8758
@rohan8758 3 месяца назад
Understood! Such an awesome explanation as always, thank you very much!!🤓
@stith_pragya
@stith_pragya 8 месяцев назад
Thank You So Much for this wonderful video...................🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻
@shitizgoel5027
@shitizgoel5027 7 месяцев назад
Very nice explanation for union-find algorithm. Thank you very much bhaiya! 🙂
@Dontpushyour_luck
@Dontpushyour_luck Год назад
This was such a nice video. Thank you for teaching all this for free!
@utkarshsingh7197
@utkarshsingh7197 Год назад
Teaching with such a fluency.....Big Fan Sir!!
@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
@saniyapathan8968
@saniyapathan8968 Месяц назад
You are the best🙌
@vijayarana2087
@vijayarana2087 Год назад
Thanks for creating this video, wonderful explanation
@pulkitjain5159
@pulkitjain5159 Год назад
wrote this code by myself in starting 11 minutes of video , ur explanation is outstandning. class DSU{ int cap; int * parent; int * rank; public: DSU(int capacity){ cap = capacity; parent = new int[cap+1]; for(int i=0;i rank[par2]){ // leader 1 is better , leader 2 will join leader 1's group parent[par2] = par1; }else if(rank[par1] < rank[par2]){ // leader 2 is bettetr , leader 1 will join leader 2's group parent[par1] = par2; }else{ // both are equal so let leader 2 join leader 1's group parent[par2] = par1; // make leader 1 a better leader rank[par1]++; } } };
@Ballistic_Bytes
@Ballistic_Bytes 8 месяцев назад
Brilliant explanation. Loved it.
@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!
@rishabh7215
@rishabh7215 Месяц назад
Finding union by size to be more intuitive so I guess I'll follow that over union by rank
@AlokSingh-jw8fr
@AlokSingh-jw8fr Год назад
Understood everything you taught in video.
@chirag.3082
@chirag.3082 Месяц назад
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
@Qwerty-yi3js
@Qwerty-yi3js 12 дней назад
I think I need to watch it again and again...to get a hold of it...
@rohitn6333
@rohitn6333 Год назад
Thanks for this wonderful explanation sir
@viraag8667
@viraag8667 2 месяца назад
You made this topic look very easy thanks
@oqant0424
@oqant0424 Год назад
No one can teach like you!
@adityasood04
@adityasood04 29 дней назад
25:30 Keep it 1 was epic😂
@SachinKumar-zs6hm
@SachinKumar-zs6hm Месяц назад
Understood! Thanks a lot Striver.
@kb-ru4md
@kb-ru4md 3 месяца назад
Best videos dp and graph🙏
@kasamadhu3509
@kasamadhu3509 10 месяцев назад
union by rank , union by size are optimal solutions to union.
@vaishnavimore4860
@vaishnavimore4860 Год назад
Great explanation🚀 understood!!
@shantipriya370
@shantipriya370 7 месяцев назад
just wow.. superb explanation..
@paragroy5359
@paragroy5359 7 месяцев назад
Thanks a lot for making such videos it is really helpful. Great Content
@augustinradjou3909
@augustinradjou3909 6 месяцев назад
Astonishing work!
@vigupta-uq1pn
@vigupta-uq1pn 8 месяцев назад
goldmine for DSA🔥🔥
@vikashkumarvlogsnitj
@vikashkumarvlogsnitj 11 месяцев назад
impressed , subscribed at first video itself.
@amitp277
@amitp277 Год назад
What a detailed explanation 👏👏
@reshusingh3558
@reshusingh3558 Год назад
Understood sir ,thankyou for your support.
@mycodingparadigm
@mycodingparadigm Год назад
In the function unionByRank when you assigned parent based on rank you haven't increased the rank of parent
@gawarivivek
@gawarivivek Месяц назад
I also have the doubt. Why are we increasing the rank only in else case, and not in all three cases? Anybody, please explain.
@avocode1487
@avocode1487 Год назад
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.
@achyutpal6225
@achyutpal6225 Год назад
Understood very well. Thank you 😄😄😄😄😄😄,
@sobujkhan2602
@sobujkhan2602 7 месяцев назад
this is amazing application really very nice video
@ritwikamahapatra1432
@ritwikamahapatra1432 4 месяца назад
what an explanation! THANKYOU
@m.afnan2018
@m.afnan2018 Год назад
Understood, But I am going to try it by myself to get more clear picture.
@vaibhavsharmaiiitu9319
@vaibhavsharmaiiitu9319 Год назад
Amazing video loved it
@udaytewary3809
@udaytewary3809 Год назад
Understood bhaiya 🙏❤️
@shubhrabrahmachari7649
@shubhrabrahmachari7649 2 месяца назад
you inspired me today . Thank you
@virgarg9653
@virgarg9653 Год назад
Understood Very good bro keep it up .....
@UECAshutoshKumar
@UECAshutoshKumar 7 месяцев назад
Thank you sir 😊😁
@arnavumarkar8259
@arnavumarkar8259 Год назад
Very well explained. Thanks
@user-tk2vg5jt3l
@user-tk2vg5jt3l 2 месяца назад
Thank you bhaiya
@prathmeshadsod629
@prathmeshadsod629 Год назад
So the difference between connected components and strongly connected component is in strong connected component Graph is directed and every node is reachable to another node . In connected compo. we just need somehow they are connected. Am I right ?
@shubhamraj25
@shubhamraj25 Год назад
I guess yes till what we have studied in this lecture
@Yash-uk8ib
@Yash-uk8ib Год назад
only difference is the nature of graph and applicablity of DSU. SCC, as u mentioned will only found if graph is directed and cyclic, DSU cannot be applied here. Component is just a few nodes connected in a group. A component can be a SCC.
@ebukaegbunam8716
@ebukaegbunam8716 7 месяцев назад
ultimate teacher
@abhishekkuntare4640
@abhishekkuntare4640 Год назад
Understood all the stuffs ❤❤
@debajyatibanerjee5480
@debajyatibanerjee5480 Год назад
#striver could u plzz cover LeetCode 1489. Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree Problem... ???
@harshsrivastava2179
@harshsrivastava2179 2 месяца назад
class DisjointSet{ vectorrank,parent,size; public: DisjointSet(int n){ rank.resize(n+1); parent.resize(n+1); size.resize(n+1); for(int i=0;i
@user-lc2lp8zb6l
@user-lc2lp8zb6l 8 месяцев назад
amazingly explained
@sunilpanchal1498
@sunilpanchal1498 Год назад
As always great explanation 🙂
@gautamsaxena4647
@gautamsaxena4647 2 месяца назад
understood bhaiya
@codingid5470
@codingid5470 Год назад
Wow such clear explanation!
@amanbhadani8840
@amanbhadani8840 Год назад
Striver Bhaiya op 🥳
@devchaudhary5002
@devchaudhary5002 Год назад
Fantastic explanation! thanks a lot my man
@rushidesai2836
@rushidesai2836 7 месяцев назад
Very well explained!
@adebisisheriff159
@adebisisheriff159 6 месяцев назад
Amazing content as always!!!!
@Shubham_gupta18
@Shubham_gupta18 3 месяца назад
best of all !! kudos to you bro
@herculean6748
@herculean6748 Год назад
lots of love and respect🙌
@rishabhgupta9846
@rishabhgupta9846 Год назад
understood ,great explanation
@anandchauhan1868
@anandchauhan1868 11 месяцев назад
Thanks for teaching
@komalkrishna7836
@komalkrishna7836 Год назад
Understood!
@sravansatapathi813
@sravansatapathi813 5 месяцев назад
Understood❤
@gauristar4094
@gauristar4094 Месяц назад
Understood!!!!!!!!!!!!
Далее
Launching the best DSA Course + Platform
36:29
Просмотров 181 тыс.
How I would learn Leetcode if I could start over
18:03
Просмотров 430 тыс.
G-48. Number of Provinces - Disjoint Set
8:03
Просмотров 67 тыс.
a little secret for binary tree questions 🤫
1:00
Просмотров 35 тыс.