Sample Printouts:

******************************************************************************************** > run AVLTestTree1 -->Add in order forcing a sequence of left rotations. Perform left rotation around: a Perform left rotation around: c Perform left rotation around: b Perform left rotation around: e ------------------------- State of Tree at Top Root Element: d Balance Factor: 0 Parent: null Left Element: b Balance Factor: 0 Parent: d Left Left Element: a Balance Factor: 0 Parent: b Left Right Element: c Balance Factor: 0 Parent: b Right Element: f Balance Factor: 0 Parent: d Right Left Element: e Balance Factor: 0 Parent: f Right Right Element: g Balance Factor: 0 Parent: f ---------------------------- -->Remove in the same order Perform left rotation around: d ------------------------- State of Tree at Top ---------------------------- -->Add in reverse order forcing a sequence of right rotations. Perform right rotation around: g Perform right rotation around: e Perform right rotation around: f Perform right rotation around: c ------------------------- State of Tree at Top Root Element: d Balance Factor: 0 Parent: null Left Element: b Balance Factor: 0 Parent: d Left Left Element: a Balance Factor: 0 Parent: b Left Right Element: c Balance Factor: 0 Parent: b Right Element: f Balance Factor: 0 Parent: d Right Left Element: e Balance Factor: 0 Parent: f Right Right Element: g Balance Factor: 0 Parent: f ---------------------------- -->Remove in the same order Perform right rotation around: d ------------------------- State of Tree at Top ---------------------------- -->Add in balanced order to avoid any rotations. ------------------------- State of Tree at Top Root Element: d Balance Factor: 0 Parent: null Left Element: b Balance Factor: 0 Parent: d Left Left Element: a Balance Factor: 0 Parent: b Left Right Element: c Balance Factor: 0 Parent: b Right Element: f Balance Factor: 0 Parent: d Right Left Element: e Balance Factor: 0 Parent: f Right Right Element: g Balance Factor: 0 Parent: f ---------------------------- -->Remove the root each time Perform right rotation around: g ------------------------- State of Tree at Top ---------------------------- ******************************************************************************************** > run AVLTestTree2 Left-Right Case 1 ------------------------- State of Tree at Top Root Element: e Balance Factor: -1 Parent: null Left Element: b Balance Factor: 1 Parent: e Left Left Element: a Balance Factor: 0 Parent: b Left Right Element: c Balance Factor: 1 Parent: b Right Element: f Balance Factor: 1 Parent: e Right Right Element: g Balance Factor: 0 Parent: f ---------------------------- Removing: f Perform left-right rotation around: e ------------------------- State of Tree at Top Root Element: c Balance Factor: 0 Parent: null Left Element: b Balance Factor: -1 Parent: c Left Left Element: a Balance Factor: 0 Parent: b Right Element: e Balance Factor: 0 Parent: c Right Left Element: d Balance Factor: 0 Parent: e Right Right Element: g Balance Factor: 0 Parent: e ---------------------------- Left-Right Case 2 ------------------------- State of Tree at Top Root Element: e Balance Factor: -1 Parent: null Left Element: b Balance Factor: 1 Parent: e Left Left Element: a Balance Factor: 0 Parent: b Left Right Element: d Balance Factor: -1 Parent: b Right Element: f Balance Factor: 1 Parent: e Right Right Element: g Balance Factor: 0 Parent: f ---------------------------- Removing: f Perform left-right rotation around: e ------------------------- State of Tree at Top Root Element: d Balance Factor: 0 Parent: null Left Element: b Balance Factor: 0 Parent: d Left Left Element: a Balance Factor: 0 Parent: b Left Right Element: c Balance Factor: 0 Parent: b Right Element: e Balance Factor: 1 Parent: d Right Right Element: g Balance Factor: 0 Parent: e ---------------------------- Left-Right Case 3 ------------------------- State of Tree at Top Root Element: f Balance Factor: -1 Parent: null Left Element: b Balance Factor: 1 Parent: f Left Left Element: a Balance Factor: 0 Parent: b Left Right Element: d Balance Factor: 0 Parent: b Right Element: g Balance Factor: 1 Parent: f Right Right Element: h Balance Factor: 0 Parent: g ---------------------------- Removing: g Perform left-right rotation around: f ------------------------- State of Tree at Top Root Element: d Balance Factor: 0 Parent: null Left Element: b Balance Factor: 0 Parent: d Left Left Element: a Balance Factor: 0 Parent: b Left Right Element: c Balance Factor: 0 Parent: b Right Element: f Balance Factor: 0 Parent: d Right Left Element: e Balance Factor: 0 Parent: f Right Right Element: h Balance Factor: 0 Parent: f ---------------------------- Left-Right Case 4 ------------------------- State of Tree at Top Root Element: e Balance Factor: -1 Parent: null Left Element: b Balance Factor: 1 Parent: e Left Right Element: c Balance Factor: 0 Parent: b Right Element: f Balance Factor: 0 Parent: e ---------------------------- Removing: f Perform left-right rotation around: e ------------------------- State of Tree at Top Root Element: c Balance Factor: 0 Parent: null Left Element: b Balance Factor: 0 Parent: c Right Element: e Balance Factor: 0 Parent: c ---------------------------- Right-Left Case 1 ------------------------- State of Tree at Top Root Element: c Balance Factor: 1 Parent: null Left Element: b Balance Factor: -1 Parent: c Left Left Element: a Balance Factor: 0 Parent: b Right Element: f Balance Factor: -1 Parent: c Right Left Element: e Balance Factor: -1 Parent: f Right Right Element: g Balance Factor: 0 Parent: f ---------------------------- Removing: b Perform right-left rotation around: c ------------------------- State of Tree at Top Root Element: e Balance Factor: 0 Parent: null Left Element: c Balance Factor: 0 Parent: e Left Left Element: a Balance Factor: 0 Parent: c Left Right Element: d Balance Factor: 0 Parent: c Right Element: f Balance Factor: 1 Parent: e Right Right Element: g Balance Factor: 0 Parent: f ---------------------------- Right-Left Case 2 ------------------------- State of Tree at Top Root Element: c Balance Factor: 1 Parent: null Left Element: b Balance Factor: -1 Parent: c Left Left Element: a Balance Factor: 0 Parent: b Right Element: f Balance Factor: -1 Parent: c Right Left Element: d Balance Factor: 1 Parent: f Right Right Element: g Balance Factor: 0 Parent: f ---------------------------- Removing: b Perform right-left rotation around: c ------------------------- State of Tree at Top Root Element: d Balance Factor: 0 Parent: null Left Element: c Balance Factor: -1 Parent: d Left Left Element: a Balance Factor: 0 Parent: c Right Element: f Balance Factor: 0 Parent: d Right Left Element: e Balance Factor: 0 Parent: f Right Right Element: g Balance Factor: 0 Parent: f ---------------------------- Right-Left Case 3 ------------------------- State of Tree at Top Root Element: c Balance Factor: 1 Parent: null Left Element: b Balance Factor: -1 Parent: c Left Left Element: a Balance Factor: 0 Parent: b Right Element: g Balance Factor: -1 Parent: c Right Left Element: e Balance Factor: 0 Parent: g Right Right Element: h Balance Factor: 0 Parent: g ---------------------------- Removing: b Perform right-left rotation around: c ------------------------- State of Tree at Top Root Element: e Balance Factor: 0 Parent: null Left Element: c Balance Factor: 0 Parent: e Left Left Element: a Balance Factor: 0 Parent: c Left Right Element: d Balance Factor: 0 Parent: c Right Element: g Balance Factor: 0 Parent: e Right Left Element: f Balance Factor: 0 Parent: g Right Right Element: h Balance Factor: 0 Parent: g ---------------------------- Right-Left Case 4 ------------------------- State of Tree at Top Root Element: e Balance Factor: 1 Parent: null Left Element: b Balance Factor: 0 Parent: e Right Element: g Balance Factor: -1 Parent: e Right Left Element: f Balance Factor: 0 Parent: g ---------------------------- Removing: b Perform right-left rotation around: e ------------------------- State of Tree at Top Root Element: f Balance Factor: 0 Parent: null Left Element: e Balance Factor: 0 Parent: f Right Element: g Balance Factor: 0 Parent: f ---------------------------- ********************************************************************************************