Top view Of Binary search tree
/*
struct node
{
int data;
node* left;
node* right;
};
*/
void inorder(node * root)
{
if(root!=NULL)
{
inorder(root->left);
printf("%d ",root->data);
}
}
void inorder1(node * root)
{
if(root!=NULL)
{
printf("%d ",root->data);
inorder1(root->right);
}
}
void top_view(node * root)
{
inorder(root->left);
printf("%d ",root->data);
inorder1(root->right);
}
struct node
{
int data;
node* left;
node* right;
};
*/
void inorder(node * root)
{
if(root!=NULL)
{
inorder(root->left);
printf("%d ",root->data);
}
}
void inorder1(node * root)
{
if(root!=NULL)
{
printf("%d ",root->data);
inorder1(root->right);
}
}
void top_view(node * root)
{
inorder(root->left);
printf("%d ",root->data);
inorder1(root->right);
}
Comments
Post a Comment