Microsoft
3.6 of 5 7,033 reviews
www.microsoft.com Redmond, WA 5000+ Employees

Microsoft Software Development Engineer Intern Interview Question (student candidate)

I interviewed in Redmond, WA and was asked:
"Print a binary tree level by level in zigzag order"
Add Tags [?]
Answer Flag Question

Part of a Software Development Engineer Intern Interview Review - one of 3,172 Microsoft Interview Reviews

Answers & Comments

1
of 1
vote
You should use two stacks: for the current level and for the next one.
- Alexey on Jan 07, 2013 Flag Response
0
of 3
votes
Use a queue.
1.Push root on queue.
2. Begin Loop Repeat while node is not equal to NULL:
            a. Pop
            b. Print value
            c. Push node's Right Child
            d. Push node's Left Child
3. End
- Nofel on Jan 27, 2013 Flag Response
1
of 1
vote
The answer given by me above is wrong because I was not clear about the zig zag ordering I applied it wrong !
- Nofel on Jan 27, 2013 Flag Response

To comment on this question, Sign In with Facebook or Sign Up


Tags are like keywords, helping to categorise interview questions that have something in common.

Glassdoor is your free inside look at Microsoft interview questions and advice. All interview reviews are posted anonymously by Microsoft employees and interview candidates.