Engineer iii interview questions shared by candidates
First phone screen: Print all the nodes of a tree in reverse level order (ie print all the nodes at the leaves first, then print the nodes on the level above the leaves, and then eventually work your way to the top).
With no additional restrictions, this sounds as though it is simply a post-order traversal of the tree.
The above answer is wrong, consider the tree below: 10 / \ 5 15 / \ 12 25 The post order traversal is 5, 12, 25, 15, 10 but the answer should be 12, 25 (or 25, 12), 5, 15 (or 15, 5) and 10 The correct solution would be to do a BFS from the room using a queue. After visiting a node, add it to a stack and continue. When done the traversal, loop the stack popping elements and printing to screen.
Do a level order traversal of the tree and reverse it. Am I missing something, or is the reverse part in there just for kicks?
See Interview Questions for Similar Jobs
- Software Engineer
- Senior Software Engineer
- Software Developer
- Software Engineer IV
- Staff Software Engineer
- Software Development Engineer
- Software Development Engineer II
- Principal Software Engineer
- Senior Software Development Engineer
- Product Manager
- Software Engineer V
- Data Scientist
- Software Development Engineer III
- Engineering Manager
- Research Scientist
- Senior Software Developer
- Software Engineer I