Question: 7. Testing Bob's manager asks him to write a method to validate a binary search tree (BST). Bob writes the following isBST method in the


7. Testing Bob's manager asks him to write a method to validate a binary search tree (BST). Bob writes the following isBST method in the IntTree class to check if a given IntTree is a valid BST. But this method has at least one fundamental bug. Answer the following questions and help Bob find the bug in his method public class IntTree private IntTreeNode overallRoot // constructors and other methods omitted for clarity private class IntTreeNode public int data public IntTreeNode left; public IntTreeNode right; // constructors omitted for clarity public boolean isBST) return isBST (overallRoot); private boolean isBST (IntTreeNode root) if (rootnul1) { else if (root.left null &&root.left.data > root.data) ( else if (root.rightnull &&root.right.dataroot.data) else return true; return false return false; return isBST (root.left) && isBST (root.right); (a) To prove that his method is correct, Bob gives you the following IntTree (Figure 1) to test his isBST methoo The isBST method recursively calls isBST on each node. In the dotted box next to each node in the tree (Figure 1) write the output of isBST ("True" or "False") when it is called on that node; write "N/A" in the box if isBST is never called on the node Figure 1: See 7a
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
