263. Given a binary tree print the nodes in this order.....
Microsoft Interview Questions and Answers
(Continued from previous question...)
263. Given a binary tree print the nodes in this order.....
Question:
Given a binary tree print the nodes in this order:
all the left most nodes from top to bottom, then all the leaves, then all the right most nodes from bottom to top, then the root. like
10
5 15
3 2 12 17
you would print 5 3 2 12 17 15 10
maybe an answer:
void FlipOrder(Node* root)
{
if (root == null) return;
if( root->left)
{
Print(Node->left->data);
FlipOrder(Node->left;
}
if( root->right)
{
FlipOrder(Node->right->data);
Print(Node->right->data);
}
Print(Node->data);
}
(Continued on next question...)
Other Interview Questions
|