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.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
29 | 30 | 1 | 2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 | 1 | 2 |