Q: Write a progam to print a binary tree such that the root is printed in the middle of its left and right sub-trees.
RTS from Rutgers says this is quite popular interview question.
the code will be like this: a binary tree can be walked as a pre order, post order or in order tree.
//e.g for in order walk
typedef struct node{
int value;
node * left;
node * right;
}btnode;
consider this
void printtree(*root)
{
node * curr = root;
printtree( curr->left);
printf(" value is %d", curr->value);
printtree(curr->right);
}
this is a recursive function call. we would also need to include boundary conditions when we reach the leaves.