⚡ Build the skills to land top-paying quant jobs. Offer ends in 17d 22h 20m 11s17 days 22 hours 20 minutes 11 seconds.
⚡ Build the skills to land top-paying quant jobs. Offer ends in 17d 22h 20m 11s17 days 22 hours 20 minutes 11 seconds.

Sign in to watch this lesson
Algorithms - Graphs I · 4:28
Depth-first search follows one road as far as it goes and backs up only when stuck, and one clock that stamps every entry and exit turns that order into structure. On a seven-node directed graph we watch nodes go white, gray and black, see the [in, out] intervals nest like parentheses (an O(1) ancestor test), and classify every edge as tree, back, forward or cross. Then we measure the price of recursion on this Mac: 64 bytes per call, so an 8 MB stack overflows around 130,000 levels, and an explicit stack of (node, next edge) frames fixes it.