0% found this document useful (0 votes)
25 views17 pages

Graphs Complete

The document discusses various graph algorithms including union find, DFS, BFS, graph coloring, topological sorting and cycle finding. It provides example problems and solutions for each algorithm type.

Uploaded by

sujeet kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views17 pages

Graphs Complete

The document discusses various graph algorithms including union find, DFS, BFS, graph coloring, topological sorting and cycle finding. It provides example problems and solutions for each algorithm type.

Uploaded by

sujeet kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 17

GRAPHS

A-Z
LEETCODE
ARTICLES
https://leetcode.com/discuss/general-d
iscussion/655708/Graph-For-Beginner
s-Problems-or-Pattern-or-Sample-Solu
tions

https://leetcode.com/discuss/study-gui
de/2360573/Become-Master-In-Graph
UNION FIND
Union Find:

Identify if problems talks about finding


groups or components.

https://leetcode.com/problems/friend-c
ircles/

https://leetcode.com/problems/redund
ant-connection/

https://leetcode.com/problems/most-st
ones-removed-with-same-row-or-colu
mn/

https://leetcode.com/problems/number
-of-operations-to-make-network-conne
cted/

https://leetcode.com/problems/satisfia
DFS
Start DFS from nodes at boundary:

https://leetcode.com/problems/surroun
ded-regions/

https://leetcode.com/problems/number
-of-enclaves/
DFS PART 2
DFS from each unvisited node/Island
problems

https://leetcode.com/problems/number
-of-closed-islands/

https://leetcode.com/problems/number
-of-islands/

https://leetcode.com/problems/keys-an
d-rooms/

https://leetcode.com/problems/max-ar
ea-of-island/

https://leetcode.com/problems/flood-fill
/
CYCLE FINDING
Breadth First Search

1. Shortest Path:
https://leetcode.com/problems/
01-matrix/

https://leetcode.com/problems/
as-far-from-land-as-possible/

https://leetcode.com/problems/r
otting-oranges/

https://leetcode.com/problems/s
hortest-path-in-binary-matrix/
GRAPH COLORING
Graph coloring/Bipartition
https://leetcode.com/problems/possibl
e-bipartition/

https://leetcode.com/problems/is-grap
h-bipartite/

Problems asks to check if its possible


to divide the graph nodes into 2
groups
Apply BFS for same. Below is a
sample graph coloring approach.
TOPO SORTING
Topological Sort:
Check if its directed acyclic graph and
we have to arrange the elements in an
order in which we need to select the
most independent node at first.
Number of in-node 0

https://leetcode.com/problems/course-
schedule/

https://leetcode.com/problems/course-
schedule-ii/
TOPO SORTING
PART 2
DFS - Iterative and recursive
solutions
LEETCODE ARTICLES
https://leetcode.com/discuss/general-d
iscussion/655708/Graph-For-Beginner
s-Problems-or-Pattern-or-Sample-Solu
tions

https://leetcode.com/discuss/study-gui
de/2360573/Become-Master-In-Graph

You might also like