Problem Statement
You are given a pointer to the root of a binary tree; print the values in in-order traversal.
You only have to complete the function.
Input Format
You are given a function,
You are given a function,
void Inorder(node *root) {
}
Output Format
Print the values on a single line separated by space.
Print the values on a single line separated by space.
Sample Input
3
/ \
5 2
/ \ /
1 4 6
Sample Output
1 5 4 3 6 2
/* you only have to complete the function given below.
Node is defined as
struct node
{
int data;
node* left;
node* right;
};
*/
void Inorder(node *root) {
if(root == NULL){
return;
}
Inorder(root->left);
cout<<root->data<<" ";
Inorder(root->right);
}
No comments:
Post a Comment