Binary Search Tree Functions: Insert A Node in BST Delete A Node in BST
Binary Search Tree Functions: Insert A Node in BST Delete A Node in BST
Binary Search Tree Functions: Insert A Node in BST Delete A Node in BST
PREORDER TRAVERSAL:
preorder(node *ptr)
{
if (root == NULL)
{
cout<<"Tree is empty"<<endl;
return;
}
if (ptr != NULL)
{
cout<<ptr->info<<" ";
preorder(ptr->left);
preorder(ptr->right);
}
}
INORDER TRAVERSAL:
inorder(node *ptr)
{
if (root == NULL)
{
cout<<"Tree is empty"<<endl;
return;
}
if (ptr != NULL)
{
inorder(ptr->left);
cout<<ptr->info<<" ";
inorder(ptr->right);
}
}