Please provide answer in C/C++. 01h:18m to test end Pranjal Srivastava 0/2 Attem
ID: 3915750 • Letter: P
Question
Please provide answer in C/C++.
01h:18m to test end Pranjal Srivastava 0/2 Attempted Cisco XR SW Dev 1 IE Creating a Binary Search Tree insert function is called. The Given a list of integers, implement the following algorithm to create a Binary Search Tree. As you create the tree, count the number of times the algorithm takes an array, keys, of n unique integers and inserts each integer in order into an empty binary search tree: // The variable named "counter counts calls to insert createBST (Int[] keys) ( set the value of counter to e for each (key in keys) ( if (tree has a root node) { insert(root, key) else ( create a new node with value 'key' as the root node of tree print the value of 'counter on a new line Insert (root, key) t Increment counter if (key is less than the value of root node) { if (root node has no left child) t create a new node with value 'key' as the left child of root node insert(left child of root node, key)Explanation / Answer
// global variable int counter; void createBST(int keys_count, int *keys) { counter = 0; for(int i=0; ileft, key); } } else if(root-> data right == null) { root->right = new Node(key); } else { insert(root->right, key); } } }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.