Disjoint Set Union By Rank and Path Compression | DSU | Graph Concepts & Qns -19| Explanation+Code
HTML-код
- Опубликовано: 26 июл 2024
- Hi Everyone, this is the 19th video of our Playlist "Graph Concepts & Qns".
In video-18, we understood a very important topic in Graph "Disjoint Set Union (DSU)"
In this video we will see the optimized version of DSU using Rank and Path Compression.
Problem Name : Disjoint Set Union By Rank and Path Compression
Topic : Graph
Video : 19
Company Tags : Google, Facebook, Apple, Amazon, Netflix, Flipkart
My GitHub Repo for interview preparation : github.com/MAZHARMIK/Intervie...
Subscribe to my channel : / @codestorywithmik
0:00 - Intro & Recap
1:20 - Understanding Path Compression from Example
8:12 - find() using Path Compression
10:04 - Understanding Rank from Example
12:55 - Why Larger Rank is chosen as Parent
17:04 - union() using Rank
╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝
#coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #hindiexplanation #hindiexplained #easyexplaination #interview #interviewtips
#interviewpreparation #interview_ds_algo #hinglish
Guys, today’s Leetcode Challenge will be uploaded now. Stay tuned today ❤
Thanks a lot man ❣.
You have earned our request.
Most awaited video
itna wait to fifa ka bhi ni kiya tha🙄
ok brother , jaldi kar dena ❣.
Kab upload karoge yaar?
This explanation of Disjoint Set Union by Rank and Path Compression is amazing! ❤Thank you for breaking it down so well!❤
Bhaiya DSU kya sach me itna easy hai..
Thank you❣
Jiska rank jyaada hai vo papa banega 😂😂😂 best line ... your teaching is top notch, thanks a lot❤
sahi mein bhai 🤣🤣🤣
You are by far the best DSA tutor I have ever studied from 🙏🏻
amazing explanation!!
19/40 done ✅ thanks a lot bhaiya😊❣ you made disjoint sets, a cakewalk for us what a great explanation 🥹
Most welcome 😊
Your way of explanation is very good.This channel will see very much growth in the future.Hope you complete 100K this year
You are doing wonders. I feel bad for those who are struggling to pay huge fees for paid courses and missing this legend's channel
You are very Great at explanation also I like your approach to solving problems with stories.
Thank you very much! 🙏
This is one of the best explanations on DSU
Amazing explanation !!!
bhai kya hi smjate ho aap mja aa gya !!!
Jiska rank jyda hai wo papa banega😂😂 Love the way you explain
😅❤️🙏
These videos are masterpiece
Thanks sir ❤
great
BEST!
Wow bhai
after learning from you , I can surely say that no one can make me understand the concepts better than you. I really wanna know or you can say very eager to know who taught you DSA . schme dil se lagta hai ki apse better dsa pure utube pe koi solve nhi kr skta. really wanna know ki apko kisne padhaya tha?
ans nhi diya apne mik bhaiya?🥺
Hello Tanish 🙏❤️
Actually I am a self taught tutor.
I never took any paid course. I studied everything from internet and from varied sources, books etc.
I never even took Leetcode Premium membership 🤣🙈
I really appreciate your kind words. I am so happy to connect with you people.
Would love to have all of you under one roof where we all can talk and interact someday.
Please remember, i am just like you. You can also solve these. Just keep practising. We all are on same level.
Thanks again ❤️❤️🙏🙏
I have mentioned your comment on my Instagram also. Thank you for making my day ❤️🙏
@@codestorywithMIK Thank you for helping me to get the DSA fear out of me.❤
U explained it so so well ☺
Thanks from the bottom of my heart :)
Thank you 😇🙏❤️
basically , rank signifies the length of longest path from parent (root) to leaf node.
so if rank[0] = 2 , that means there are 2 levels in tree path.
✅
Bro, you should also mention union by size as it is lot more intuitive than the rank one. BTW the content is gold😍
Indeed. Actually the actual DSU mentions about rank and path compression. I have kept size in hold until I solve a Qn which will compel us to introduce size also. That will be intuitive and make us think that YES, That’s why we need size. Will post that qn soon
Thanks again for your precious feedback ❤️❤️❤️
addicted to your videos.❤
Thanks a lot Aryan ❤️
how this can be so easy. great content!
Thank you so much ❤️
this explanation was so good union .please explain union by size too
Thanks a lot.
I will upload Union By size this weekend 😇🙏
path compression is same like using dp
19/41 done [6.11.23] ✅✅
Why only increase the rank when the ranks are equal? What if when doing a union, even if the rank of a node is less than the other, but it can be connected to a parent which is having a higher rank? How do we handle this? Pretty confusing.
but bhaiya , hum toh path compression se agar height wali factor hata hi rhe hai , toh same time rank ka kya hi significance reh gya ?
Thoda samjha do na pls
Bhaiya.. Graph ke kuch questions Java me bhi solve kar dijiye!! Helpful hoga ❤️
Sure Rishabh. I will try to provide java too.
Also some people add java code in comments, i will PIN then in case i get it
Thanks again for watching my videos
@@codestorywithMIK Thanks for consideration, if you could provide java code in your style, with video, story and then code conversion, it will help a lot of folks..
can you give me leetcode question no that you are talking about
Graph count = 19
kitne baje ayega sir, agar late ayega toh phir mai khudse karne ki koshish karunga pls btao time approx
bro you should try yourself first , if you are not able to solve then see videos otherwise you would not able to think approach in interviews.
Being uploaded. Little Length , youtube taking time to upload
jiska rank jyada hota h voo papa banta h ye hi bola tha maine apne dosto ko bhi 🤣🤣🤣🤣🤣
Perfect 😅
are you in to competitive programming? if you are then please share your codeforces profile
Hi there,
Unfortunately No. i have not tried CP
when to use dsu rank and size ?q
I would suggest always use rank and size compression in DSU. It’s an optimised version
@@codestorywithMIK In yesterday's contest I used dsu union by size which worked but If i use by rank it's giving wrong answer. And can u upload a video on dsu union by size as it's lot more intuitive
I see. Now i got your qn.
Yes yes, union by size and rank are different.
I will upload a qn on dsu which will help explain dsu by size
@@codestorywithMIK what's the difference in both?
Let me create a video on it soon to deep dive into it
can we have your socials Id's for help🙏
Soon I will create. Will plan
Thanks for the suggestion ❤️
how you explain every thing so easily and nicely🥹🥹🥹🥹🥹
Thank you so much 🙏🙏❤️❤️