Skip to content

Instantly share code, notes, and snippets.

@shemul
Created November 18, 2014 10:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shemul/a821222a32acc267b6bb to your computer and use it in GitHub Desktop.
Save shemul/a821222a32acc267b6bb to your computer and use it in GitHub Desktop.
main BST
#include "func.h"
using namespace std;
Tleaf main_root = NULL;
int main()
{
int x ;
for (int i = 0 ; i <3 ; i++)
{
cin >> x ;
main_root = makeThetree(main_root,x);
}
cout << "Preview in Inorder: " << endl;
inOrder(main_root);
cout << endl;
cout << "Preview in POSTORDER: " << endl;
postOrder(main_root);
cout << endl;
cout << "Preview in PREORDER: " << endl;
preOrder(main_root);
cout << endl<< endl;
DrawTheTree(main_root);
cout << endl <<endl ;
cout << "Search !";
cin >> x;
/* if ( searchInTree(main_root,x) == NULL)
{
cout << "NOT FOUND.." <<endl;
cout << "Adding the value in the Tree" <<endl ;
makeThetree(main_root,x);
cout << "New Iteam Added ! Preview : " <<endl ;
inOrder(main_root);
} else {
cout << "FOUND" ;
}*/
searchInTree(main_root,x);
if(searchInTree(main_root,x)==1)
{
cout << "Adding the value in the Tree" <<endl ;
makeThetree(main_root,x);
cout << "New Iteam Added ! Preview : " <<endl ;
inOrder(main_root);
cout << endl << endl ;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment