Answered step by step
Verified Expert Solution
Question
1 Approved Answer
i need code for this method java lungu Method Discerption private TreeNode This method searches the tree and tries to search(int key, TreeNode find the
i need code for this method
Method Discerption private TreeNode This method searches the tree and tries to search(int key, TreeNode find the node with the given key. If the key subRoot) is not found it should return null, otherwise it should return the node that has the key 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 void This method is used to check if the balance Tree(TreeNode subRoot node is left imbalanced subRoot, TreeNode prev) (balFactor 2) or right imbalanced (balFactor == -2). Then, it should call the appropriate rotation methods to re- balance the tree. private void This method replaces subRoot with its rotate Left(TreeNode right child and makes the subRoot the left subRoot, TreeNode prev) child of the child that replaced it. private void This method replaces subRoot with its left rotate Right(TreeNode child and makes the subRoot the right subRoot, TreeNode prev) child of the child that replaced it. private void This method calls rotate Right with rotate RightLeft(TreeNode subRoot's right child. Then, it calls subRoot, TreeNode prev) rotateLeft on the subRoot itself. private void This method calls rotateLeft with rotate LeftRight(TreeNode subRoot's left child. Then, it calls subRoot, TreeNode prev) rotate Right on the subRoot itself java lungu
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