Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "headers.h"
- #include "stdio.h"
- // Driver Program to test BTree functions
- int main()
- {
- /* Let us create following BST
- 70
- / \
- 60 80
- / \
- 30 50
- / /
- 20 40
- */
- TREE* bTree;
- bTree = createControlStructure();
- int iValues[] = {70,60,30,50,40,80,20};
- struct node *root = bTree->root;
- for (int i = 0; i <=6; i++) {
- root = insertLeaf(root, iValues[i], i);
- }
- printf("\nPreorder traversal of binary tree is \n");
- printPreorder(root);
- printf("\nInorder traversal of binary tree is \n");
- printInorder(root);
- printf("\nPostorder traversal of binary tree is \n");
- printPostorder(root);
- printf("\nFreeing up memory of binary tree: \n");
- deleteBTree(root);
- int val;
- printf("Please enter a value to search for, 0 to exit\n");
- scanf("%d", &val);
- while(val != 0) {
- printf("fattoush");
- searchBTree(root, val);
- main();
- if(val==0) {
- printf("Please enter a value to delete ");
- scanf("%d", &val);
- }
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement