Skip to content

Commit

Permalink
Main program for Binary Search tree
Browse files Browse the repository at this point in the history
  • Loading branch information
msindev committed Oct 2, 2018
1 parent d09e780 commit 0e876ac
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions Binary Search Tree/bst-main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include "bst.h"

int main()
{
struct bstree *root = NULL, *newnode;
int choice, num;
while (1)
{
printf("1. Insert Element in Tree\n 2. Delete Element from Tree\n 3. Tree Traversals\n 4. EXIT\n");
scanf("%d", &choice);
switch(choice)
{
case 1:
newnode = getnode();
printf("Enter number to enter: ");
scanf("%d", &num);
newnode -> data = num;
root = insert(root, newnode);
break;
case 2:
printf("Enter number to delete: ");
scanf("%d", &num);
root = delete(root, num);
break;
case 3:
printf("\n PreOrder Traversal: ");
preorder(root);
printf("\n InOrder Traversal: ");
inorder(root);
printf("\n PostOrder Traversal: ");
postorder(root);
break;
case 4:
exit(0);
default:
printf("Wrong Choice\n");
}
}
return 0;
}

0 comments on commit 0e876ac

Please sign in to comment.