Showing Posts From

Bfs

Graphs 101: BFS & DFS Traversals

Graphs 101: BFS & DFS Traversals

Week 14 notes: a tree is just a graph without cycles. Graph representations, DFS and BFS with a visited set, shortest paths on unweighted graphs, and grids as graphs.

N-ary Trees: Traversal & Encoding

N-ary Trees: Traversal & Encoding

Week 13 notes: once a node can have any number of children, the binary-tree patterns still work, you just loop over children. Plus encoding an N-ary tree as a binary one.

Binary Trees: Traversals & DFS / BFS

Binary Trees: Traversals & DFS / BFS

Week 10 notes: binary trees are basically recursion you can draw. The three DFS orders, level-order BFS, and the one move that solves most tree problems.