Write a program print the outsides nodes in a binary tree.
Risposte di colloquio
Anonimo
13 feb 2013
using DFS.
Anonimo
15 feb 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.
Anonimo
30 lug 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