Potato Coders
Potato Coders
  • 7
  • 213 555
Union Find in 5 minutes — Data Structures & Algorithms
This video covers one of the most popular data structures and algorithms topic "Union Find". This is an instruction showing how to run Union-Find on a graph, with examples and code. Union Find and Disjoint Set are not as difficult as we think! 😊
#graph #data_structures #algorithms #faang #Union-find #disjoint set #data-structures #recursion #leetcode #interview #algo #disjoint-sets #disjoint sets
Facebook: PotatoCoders/
Linkedin: linkedin.com/company/potato-coders
มุมมอง: 193 145

วีดีโอ

Recursion Interview Question - "Kth Symbol in Grammar" (Data Structures & Algorithms)
มุมมอง 12K3 ปีที่แล้ว
0:12 - Problem description 1:02 - Problem examples 1:37 - Algorithm Explanation 4:24 - Pseudocode (explains idea behind algorithm) 5:55 - Full code solution (explains idea behind implementation) 7:04 - Time Space Complexity Here's the explanation on how to solve popular Data Structure & Algorithms question on Leetcode, "Kth Symbol in Grammar". This is a classic question that we get from technic...
Graph Interview Question - Course Schedule (Topological Sort)
มุมมอง 4.7K3 ปีที่แล้ว
Please like and subscribe! Comment any of your feedback down below. 😃 Here's the explanation on how to solve popular Data Structure & Algorithms question on Leetcode, "Course Schedule". This is a classic question that we get from technical interviews at Google, Facebook, Amazon, Microsoft, and so on. Let’s try this question to learn more about topological sorting, kahn’s algorithm, graph traver...
Facebook Coding Interview Question - Merge Two Binary Trees
มุมมอง 1.9K3 ปีที่แล้ว
Here's the explanation on how to solve popular Data Structure & Algorithms question on Leetcode, "Merge Two Binary Trees". This is a classic question that we get from technical interviews at Google, Facebook, Amazon, Microsoft, and so on. Let’s try this question to learn more about binary trees and recursion. Feel free to comment any questions!
Stack Interview Problem - Check Balanced Parentheses ("Valid Parentheses" on Leetcode)
มุมมอง 1.1K3 ปีที่แล้ว
Leetcode #20. Valid Parentheses leetcode.com/problems/valid-parentheses Stack Question

ความคิดเห็น

  • @danielwang8833
    @danielwang8833 11 วันที่ผ่านมา

    Really clear and concise explanation. This video helped a ton.

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

    bro... come back ur vids r so good 😭

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

    Wer sieht das auch für's HAW Studium?

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

    Thank you! This was very helpful

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

    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

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

    Solved my hours long quandary in 5 minutes. Thank you!

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

    Great explaination with beautiful graph!!! Love it with your DSA explaination.

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

    Great explanation

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

    is there any other way to do it?

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

    very clear! Thanks!

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

    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.

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

    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 5 หลายเดือนก่อน

    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 6 หลายเดือนก่อน

    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_ 4 หลายเดือนก่อน

      this is my question too. It looks like the operations are constant for each level?

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

    This was actually insanely helpful in understanding the concept. Thanks!

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

    It so simple and straight forward. Thanks you so much

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

    beauty

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

    That was so easy i spent an hour on this😭😭😭

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

    The Big-Theta runtime for find() would be Θ(n).

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

    You got a video on path compression?

  • @harshit-jain.
    @harshit-jain. 10 หลายเดือนก่อน

    Really great explanation. Couldn't understand it earlier but now got it. Thank you.

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

    good video

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

    Great explanation. Was able to recall what I had learnt a while back. Thank you!

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

    Bro this topic is confusing AF, but at least this vid makes it somewhat understandable

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

    Thanks Mr. Tater.

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

    Thank you very much. Nice video.

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

    Amazing! It's very clear. Thank you

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

    Best explanation in this question

  • @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 ปีที่แล้ว

    really kool I have same approach in mind but wasn't able to solve thanks for the video

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

    Thank you so much this is great!

  • @surajbaranwal56.
    @surajbaranwal56. ปีที่แล้ว

    Great explain, helpful visuals. Thnaks

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

    Thank you so much man

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

    Thanks

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

    awesome

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

    fantastic video! thanks!!!

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

    Beautiful demonstration with clear mind

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

    best explanation every ! :D

  • @12345ms
    @12345ms ปีที่แล้ว

    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 ปีที่แล้ว

    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!

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

    thanks a lot for explaining in few minutes.

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

    Amazing video, very easy to follow, thank you! 🎉

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

    There are two issues here: 1. When performing union, you set parent of the smaller set to the representative of the larger set. 2. When finding a path, you compress the path on your way back, improving O(logn) ops to O(log* n) in average.

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

      what do you mean by O(log* n) what is the *?

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

    dood this is amazing please do more videos man , like dp problems