• Number of Connected Components in an Undirected Graph

    Problem https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph/ Solution #1. DFS Solution #2. Union Find Read more

  • Graph Valid Tree

    Problem https://leetcode.com/problems/graph-valid-tree/description/ Solution #1. DFS Solution #2. Union-Find Solution #3. Union-Find with boolean type Read more

  • Number of Provinces

    Problem https://leetcode.com/explore/featured/card/graph/618/disjoint-set/3845/ Solution Read more

  • Disjoint Set (Union-Find)

    What is Disjoint Set ? Idea of Union-Find #1. Parent Vertex를 저장하는 배열을 만든다. #2. 각 Edge 를 돌면서 parent vertex를 업데이트한다. (Union) #3. Connectivity 확인 (Find) Quick Find – Improved Idea of Union-Find #1 위에서 서술한 방법에서 조금만 개선하면 더 나은 알고리즘이 될 수 있다. parent vertex 배열을 root vertex 배열로 만들어주는것! 즉, Union Read more

  • Kahn’s Algorithm – Topological Sorting

    문제들 중, graph 에서 특정 노드를 방문하기 전에 다른 노드를 반드시 방문해야하는 케이스들이 있다. 예를 들어, 수강하고자 하는 강의는 선수강 강의가 있어서 해당 강의를 먼저 들어야 하는등.. 이런 경우 DFS 를 통해 문제를 푸는것도 가능하지만, Kahn’s Algorithm 을 통해 문제를 풀 수 있다! Algorithm 1. inDegree(=incoming path 갯수) 가 0인 node 들을 queue 에 넣는다. Read more

  • Pacific Atlantic Water Flow

    Problem https://leetcode.com/problems/pacific-atlantic-water-flow/description/ Solution Read more