Question d’entretien chez Google

Write a program print the outsides nodes in a binary tree.

Réponses aux questions d'entretien

Utilisateur anonyme

13 févr. 2013

using DFS.

Utilisateur anonyme

15 févr. 2013

Level order traversal with two array like buffers - one for level i and other for level i+1. store nodes in level ordered fashion in array and print 0th and (n-1)th element of that array.

Utilisateur anonyme

30 juill. 2013

Parag, that won't work, you might have leaf nodes at height-2 or higher. Here's a solution that uses pre-order traversal: http://www.fusu.us/2013/07/printing-binary-tree-boundary.html