Qualcomm interview question

Depth first search. Stack and heap, etc.