Question: 3.2.32 Certification. Write a method isBST() that takes a Node as argument and returns true if the argument node is the root of a binary

3.2.32 Certification. Write a method isBST() that takes a Node as argument and returns true if the argument node is the root of a binary search tree, false otherwise. Hint : This task is also more difficult than it might seem, because the order in which you call the methods in the previous three exercises is important.

Solution : private boolean isBST() { if (!isBinaryTree(root)) return false; if (!isOrdered(root, min(), max())) return false; if (!hasNoDuplicates(root)) return false; return true; }

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!