Write A Program Which Can Add and Display A Binary Search Tree
Write A Program Which Can Add and Display A Binary Search Tree
Write a program which can add and display a binary search tree
#include <iostream>
struct node
{
int info;
node *left;
node *right;
};
node *root = NULL;
node* newNode(int d)
{
node *tmp = new node;
tmp->info = d;
tmp->left = NULL;
tmp->right = NULL;
return tmp;
}
printInorder(n->left);
printInorder(n->right);
}
return n;
}
}
int main()
{
//cout << "Starting";
root = insertNode(root, 25);
insertNode(root, 15);
insertNode(root, 10);
insertNode(root, 50);
insertNode(root, 20);
cout << endl <<endl << "Printing inorder: " <<endl <<endl;
printInorder(root);
deleteNode(root, 25);
cout <<endl <<endl;
printInorder(root);
//cout << root->left->left->info <<endl;
//cout << root->left->info <<endl;
//cout << root->info <<endl;
// cout << root->right->info <<endl;
/*
insertNode(root, 12);
insertNode(root, 10);
insertNode(root, 15);
insertNode(root, 14);
preorderTraversal(root);*/
return 0;
}