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
Get step-by-step solutions from verified subject matter experts
