Пікірлер
@gregoriuswillson4153
@gregoriuswillson4153 10 күн бұрын
Great content bro
@vinitsunita
@vinitsunita Ай бұрын
Awesome explaination
@collyyang9664
@collyyang9664 2 ай бұрын
good, thank you very much
@UsamaAziz-lb7ky
@UsamaAziz-lb7ky 3 ай бұрын
Great video, worth adding path compression as well.
@HimanshJainYTube
@HimanshJainYTube 4 ай бұрын
Beautifully explained. Thank you.
@danielwang8833
@danielwang8833 5 ай бұрын
Really clear and concise explanation. This video helped a ton.
@mykz814
@mykz814 6 ай бұрын
bro... come back ur vids r so good 😭
@Luca_040
@Luca_040 6 ай бұрын
Wer sieht das auch für's HAW Studium?
@Hdhdushzhz57743
@Hdhdushzhz57743 8 ай бұрын
Thank you! This was very helpful
@jashmerchant5121
@jashmerchant5121 9 ай бұрын
Python code: # WITH Path Compression def find(self, parent, x): # finds root or representative of disjoint-set/union if parent[x] != x: parent[x] = self.find(parent, parent[x]) # path compression step return parent[x] def union(self, parent, x, y): root_x = self.find(parent, x) root_y = self.find(parent, y) parent[root_x] = root_y # WITHOUT Path Compression def find(self, parent, x): # finds root or representative of disjoint-set/union if parent[x] != x: return self.find(parent, parent[x]) return parent[x] def union(self, parent, x, y): root_x = self.find(parent, x) root_y = self.find(parent, y) parent[root_x] = root_y
@austecon6818
@austecon6818 3 ай бұрын
Thanks and other implementations include rank. Does it matter?
@jashmerchant5121
@jashmerchant5121 9 ай бұрын
Solved my hours long quandary in 5 minutes. Thank you!
@chithyFly
@chithyFly 9 ай бұрын
Great explaination with beautiful graph!!! Love it with your DSA explaination.
@civilspot5912
@civilspot5912 9 ай бұрын
Great explanation
@sauravnegi8858
@sauravnegi8858 9 ай бұрын
is there any other way to do it?
@nguyennguyendinh5215
@nguyennguyendinh5215 9 ай бұрын
very clear! Thanks!
@BobTheScience
@BobTheScience 10 ай бұрын
To optimize it, the find function should set the parent of it's parent to find(x). (This will probably help a lot) function find(x): if Parent[x] != x: parent[x] = find(parent[x]) return parent[x] If I'm wrong please tell me.
@nomealow
@nomealow 3 ай бұрын
Yes, this is called path compression, by setting the parent of x and all of the ancestors of x to be the root ancestor of x. This makes it so that find(), for that particular tree in the future, will be O(1) instead of being dependent on the tree depth
@tenminuteamateurhour
@tenminuteamateurhour 10 ай бұрын
Correction, this does not run in O(logn), but in O(n). To get O(logn) optimization, you need to use union by rank or by size.
@chku
@chku 11 ай бұрын
This video is so gud but looks like the channel ain't active anymkre 🥺💔 I really loved the explanation n quality so thankuu n hope u r doing well ✨
@SahilJSawant
@SahilJSawant 11 ай бұрын
But why are you doing log K I think for every level you are just doing one operation so the time complexity is just O(N)
@ben94_
@ben94_ 9 ай бұрын
this is my question too. It looks like the operations are constant for each level?
@richtigmann1
@richtigmann1 11 ай бұрын
This was actually insanely helpful in understanding the concept. Thanks!
@nghiapham1632
@nghiapham1632 Жыл бұрын
It so simple and straight forward. Thanks you so much
@samuraipiyush
@samuraipiyush Жыл бұрын
beauty
@amrutaparab4939
@amrutaparab4939 Жыл бұрын
That was so easy i spent an hour on this😭😭😭
@rasheedlewis1
@rasheedlewis1 Жыл бұрын
The Big-Theta runtime for find() would be Θ(n).
@aadityakiran_s
@aadityakiran_s Жыл бұрын
You got a video on path compression?
@harshit-jain.
@harshit-jain. Жыл бұрын
Really great explanation. Couldn't understand it earlier but now got it. Thank you.
@pamp3657
@pamp3657 Жыл бұрын
good video
@DeepakSankar88
@DeepakSankar88 Жыл бұрын
Great explanation. Was able to recall what I had learnt a while back. Thank you!
@chrisdahms9682
@chrisdahms9682 Жыл бұрын
Bro this topic is confusing AF, but at least this vid makes it somewhat understandable
@Rockyzach88
@Rockyzach88 Жыл бұрын
Thanks Mr. Tater.
@persas1683
@persas1683 Жыл бұрын
Thank you very much. Nice video.
@chrismiaomiao9426
@chrismiaomiao9426 Жыл бұрын
Amazing! It's very clear. Thank you
@lostgoat
@lostgoat Жыл бұрын
This is O(n) time complexity the modulo is a constant operation, also since were only modding 2 here we can just check the first bit in k to see if its a 1 or 0
@WebSurfingIsMyPastime
@WebSurfingIsMyPastime Жыл бұрын
This video was great! definitely not something that's very clearly covered in alot of other sources
@manojmpatil1269
@manojmpatil1269 Жыл бұрын
Perfectly explained. Thanks
@ahmetemin7572
@ahmetemin7572 Жыл бұрын
Short and clear, thanks
@arjunv7055
@arjunv7055 Жыл бұрын
wonderful explanation! Thanks mate!
@vivstyles1765
@vivstyles1765 Жыл бұрын
Still don’t understand shit
@MinhPham-eh6lr
@MinhPham-eh6lr Жыл бұрын
Thanks for the concise and easy-to-understand explanation!
@dollyakshaya7535
@dollyakshaya7535 2 жыл бұрын
really kool I have same approach in mind but wasn't able to solve thanks for the video
@JamesBrodski
@JamesBrodski 2 жыл бұрын
Thank you so much this is great!
@surajbaranwal56.
@surajbaranwal56. 2 жыл бұрын
Great explain, helpful visuals. Thnaks
@samwilson4597
@samwilson4597 2 жыл бұрын
Thank you so much man
@KoScosss
@KoScosss 2 жыл бұрын
Thanks
@corgirun7892
@corgirun7892 2 жыл бұрын
awesome
@jakobmusic9187
@jakobmusic9187 2 жыл бұрын
fantastic video! thanks!!!
@ppsor329
@ppsor329 2 жыл бұрын
Beautiful demonstration with clear mind
@piotr780
@piotr780 2 жыл бұрын
best explanation every ! :D
@12345ms
@12345ms 2 жыл бұрын
Why do we need to take ceil for k/2 i.e. k/2+k%2? Why just k/2 does not work, can someone explain, please? Thank you.
@markomekjavic
@markomekjavic 2 жыл бұрын
Really love your explanation and your simplistic code! This is by far the best video content on the topic I've seen so far, many thanks!