Professional Documents
Culture Documents
Left Node ROOT Right Node
Left Node ROOT Right Node
Left Node ROOT Right Node
#include<stdio.h>
#include<stdlib.h>
struct node{
int data;
struct node *lchild, *rchild;
};
void createBST(){
int n;
struct node *temp, *trav;
temp = (struct node*)malloc(sizeof(struct
node));
printf("\nEnter the key value (data part) of the
new node: ");
scanf("%d", &n);
temp->data = n;
temp->lchild = NULL;
temp->rchild = NULL;
trav = root;
while( 1 ){
else if ( trav->data == x )
return trav;
else
search(x, trav->rchild);
if( s != NULL )
printf("\nThe node %d is in the BST...", s-
>data);
else
printf("\nThe node is not in the BST....");
void main(){
inorder(root);
s = search(20, root);
check(s);
}