Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Complete the validBST() method so that it returns true if it is a leaf OR (its element is ordered properly relative to its child(ren) AND
Complete the validBST() method so that it returns true if it is a leaf OR (its element is ordered properly relative to its child(ren) AND its child(ren) are also valid BST entries). If neither of those things is correct, thn the method should return false. public class Entry> { /** Tree's element which is stored within this Entry. */ private E element; /** Left child of the current Entry. */ private Entry left; /** Right child of the current Entry. */ private Entry right; /** Parent in the binary tree for the current Entry. */ private Entry parent; /** * Creates a new BSTEntry object with the specified element and parent BSTEntry. * * @param element Data to be held in this BSTEntry. * @param parent Parent for this entry within the binary tree. */ public Entry(E element, Entry parent) { this.element = element; this.parent = parent; } /** * Validates whether the this Entry is ordered legally with respect to its child(ren) AND if any children are also * legal. It might still be possible for the BST rooted at this Entry to not be perfectly legal, but this does a good * enough job while making certain students understand how BSTs work. * * @return True if this Entry is a leaf OR (its element is ordered properly with respect to its child(ren) AND its * child(ren) are also valid BST entries; false if this Entry or any descendant is not legally ordered. */ public boolean validBSTEntry() { } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started