Question: Examine the following code to add a node to BST. Logic is correct, but the tree is empty (never being able to insert a node).

 Examine the following code to add a node to BST. Logic

Examine the following code to add a node to BST. Logic is correct, but the tree is empty (never being able to insert a node). Explain why the following code is not working in your own words. public class SearchTree { private IntTreeNode overall Root; // Adds the given value to this BST in sorted order. 11 (THIS CODE DOES NOT WORK PROPERLY!) public void add(int value) { addCoverall Root, value); } private void add(IntTreeNode node, int value) { if (node == null) { node = new IntTreeNode(value); } else if (value node.data) { add(node.right, value); } // else a duplicate (don't add) }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!