Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in 1d 16h 01m 51s1 days 16 hours 1 minutes 51 seconds.
Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in 1d 16h 01m 51s1 days 16 hours 1 minutes 51 seconds.

Sign in to watch this lesson
Algorithms - Linear Data Structures · 4:14
A stack pushes, pops and peeks at one end in constant time. We check brackets character by character on {[()()]}( and ([)], see why a stack is the memory of the most recent unfinished thing (calls, undo, depth-first search, postfix), and keep a running maximum beside every entry so an undo costs nothing. On this Mac we compare vector with std::stack and watch a recursive DFS crash at about 130,000 levels while an explicit stack visits a million nodes.