Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in 1d 16h 01m 48s1 days 16 hours 1 minutes 48 seconds.
Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in 1d 16h 01m 48s1 days 16 hours 1 minutes 48 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.