Question: /* * private insert */ private boolean insert(int key, TreeNode subRoot, TreeNode prev) { /* * INSERT YOUR CODE HERE. */ } /* * private


/* * private insert */ private boolean insert(int key, TreeNode subRoot, TreeNode prev) { /* * INSERT YOUR CODE HERE. */ }
/* * private delete * * The arguments to this method are a bit of a kludge because * Java doesn't support pointers - at least not in any good way. :{ * So if on return from this method the key value in TreeNode data is * set to null, then the key wasn't found. Otherwise, the node was * found and it's key value is set to the appropriate value. */ private boolean delete(int key, TreeNode subRoot, TreeNode prev, TreeNode data) { /* * INSERT YOUR CODE HERE. */ }
private boolean insert(int This method does the insertion work but key, TreeNode subRoot, should make sure that the tree is a valid TreeNode prev) AVL tree after the insertion. Hence, this method may call the balance Tree method. The Boolean value returned by this method is used to indicate whether the height of the subtree rooted at subRoot has changed or not. private boolean delete(int This method does the deletion work and key, TreeNode subRoot, also make sure the tree is a valid AVL tree TreeNode prev, TreeNode after the deletion. Hence, this method may data) call the balanceTree() method. The deleted node should be placed in the data parameter passed. If the key is not found, this data parameter should not change. The Boolean value returned by this method is used to indicate whether the height of the subtree rooted at subRoot has changed or not. private boolean insert(int This method does the insertion work but key, TreeNode subRoot, should make sure that the tree is a valid TreeNode prev) AVL tree after the insertion. Hence, this method may call the balance Tree method. The Boolean value returned by this method is used to indicate whether the height of the subtree rooted at subRoot has changed or not. private boolean delete(int This method does the deletion work and key, TreeNode subRoot, also make sure the tree is a valid AVL tree TreeNode prev, TreeNode after the deletion. Hence, this method may data) call the balanceTree() method. The deleted node should be placed in the data parameter passed. If the key is not found, this data parameter should not change. The Boolean value returned by this method is used to indicate whether the height of the subtree rooted at subRoot has changed or not
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
