Advertisement
dmesticg

Untitled

Nov 29th, 2020
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1.  
  2. #include "headers.h"
  3. #include "stdio.h"
  4.  
  5. // Driver Program to test BTree functions
  6. int main()
  7. {
  8. /* Let us create following BST
  9.  
  10. 70
  11. / \
  12. 60 80
  13. / \
  14. 30 50
  15. / /
  16. 20 40
  17.  
  18. */
  19.  
  20. TREE* bTree;
  21. bTree = createControlStructure();
  22.  
  23. int iValues[] = {70,60,30,50,40,80,20};
  24.  
  25. struct node *root = bTree->root;
  26.  
  27. for (int i = 0; i <=6; i++) {
  28. root = insertLeaf(root, iValues[i], i);
  29. }
  30. printf("\nPreorder traversal of binary tree is \n");
  31. printPreorder(root);
  32.  
  33. printf("\nInorder traversal of binary tree is \n");
  34. printInorder(root);
  35.  
  36. printf("\nPostorder traversal of binary tree is \n");
  37. printPostorder(root);
  38.  
  39. printf("\nFreeing up memory of binary tree: \n");
  40. deleteBTree(root);
  41.  
  42. int val;
  43. printf("Please enter a value to search for, 0 to exit\n");
  44. scanf("%d", &val);
  45.  
  46.  
  47. while(val != 0) {
  48. printf("fattoush");
  49. searchBTree(root, val);
  50. main();
  51.  
  52. if(val==0) {
  53. printf("Please enter a value to delete ");
  54. scanf("%d", &val);
  55. }
  56. return 0;
  57. }
  58.  
  59.  
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement