This assignment is about being given 4 cases each one with values for a tree. If the tree has 3 levels and is unbalanced then do the appropriate rotations (right, left, right-left, and left-right). Rules state: only test for and possibly run your rebalancing code when inserting (not when deleting) and only test for and possibly run your rebalancing code for trees with 3 levels, after the insertion has taken place.
I think I'm going in the right direction. But I'm not sure, especially with the righLeftRotation() and leftRightRotation. BasicBTree(2).java was the starter file. Which was renamed to Balance.java and has methods I created (such as: isItBalanced(), leftRotation(), rightRotation(), leftRightRotation(), rightLeftRotation(), treeLevels(), height()). I also, made changes to the add() method in the Balance.java file.
Get Free Quote!
414 Experts Online