Question d’entretien chez Microsoft

Print a binary tree level by level in zigzag order

Réponses aux questions d'entretien

Utilisateur anonyme

8 janv. 2013

You should use two stacks: for the current level and for the next one.

2

Utilisateur anonyme

27 janv. 2013

The answer given by me above is wrong because I was not clear about the zig zag ordering I applied it wrong !

2

Utilisateur anonyme

27 janv. 2013

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