Skip to content
Random notes

Graph Notes

A tree is a special kind of graph - a connectedacyclic (cycle-less) graph. A graph may contain cycle(s), and nodes could be disconnected. A tree also contains n nodes and n - 1 edges, in addition to being acyclic, and there exists only 1 path between any 2 nodes in a tree.

Edges can be undirected or directed. For most interview problems, we are dealing with undirected graphs. A tree is also an undirected graph.

Union find - solid code in notes

Graph Notes