Control4 Interview Question: Travse tree without using rec... | Glassdoor

Interview Question

Senior Software Engineer Interview San Jose, CA

Travse tree without using recursion

Answer

Interview Answer

1 Answer

0

probably a binary tree i imagine... in this case you will always want to keep track of where you are in the tree so you can back track. You would want to add to the stack where you are and navigate down one side of the tree(say left side)... when you get to the bottom you can jump up one level, then check if there's a right node. if none, than that node is fully searched and you can go up another level. keep doing this until you end up at the top of the tree.

Ray Loveless on Apr 13, 2018

Add Answers or Comments

To comment on this, Sign In or Sign Up.