Write a Binary Search Tree for strings using Array implementation in C++ ! Add a
ID: 3760191 • Letter: W
Question
Write a Binary Search Tree for strings using Array implementation in C++ ! Add a balancing routing ! Test it by creating a main class. print the executable output.
Explanation / Answer
#include using namespace std; typedef struct Tree { int data; Tree *left; Tree *right; } Node; /* recursion routine to find path */ void pathFinder(Node* node, int path[], int level) { if(node == NULL) return; // leaf node save if(node->left == NULL && node->right == NULL) { path[level] = node->data; int sum = 0; for(int i = 0; i left = insertNode(new Tree, 5); nodeLeft->right = insertNode(new Tree, 7); nodeRight->left = insertNode(new Tree, 1); // path find int path[10]; pathFinder(root,path,0); return 0; } /* output */ /* 3 -1 5 sum = 7 3 -1 7 sum = 9 3 2 1 sum = 6 */Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.