Unbalanced nodes in a BSTIn today's lab, we will see balancing a Binary Search Tree (BST) using rotations. Recall that a node in a tree is unbalanced if the difference in heights of its left and right subtrees is > 1. In the example below, nodes shaded gray are unbalanced nodes and nodes shaded orange are balanced nodes. ![]() |
Overview of rotations used to balance a BST
|
Example using rotations to balance a BST
![]() ![]() |
Download class files for the lab below,
|
http://cs-people.bu.edu/tvashwin/cs112_spring08/lab07.html |