Applify Interview Question

One question that I can recall is to implement a depth-first search algorithm for a binary tree without using recursion.

Interview Answer

Anonymous

Jan 9, 2024

So, basically, I had to figure out how to explore a binary tree without using the usual recursive method. The trick was to maintain a stack, put nodes in a specific order, and deal with each one as I go through the tree. The code I wrote shows a way to do this in a step-by-step, iterative fashion.