Unformatted text preview: public int imbalance () which returns the imbalance of the tree. 2. Verify experimentally that repeated random insertions and removals from a binary search tree leads to an imbalanced tree (Figure 4.27, p 122). 3. One source of the imbalance is the asymmetry of the remove(. ..) function. Remove the asymmetry by alternating between the smallest child in the right subtree and the largest child in the left subtree. Repeat your experiment. Has the imbalance decreased? 4. Another strategy to avoid imbalance is to randomly choose between the smallest child in the right subtree and the largest child in the left subtree. Implement this behavior and repeat your experiment. 1...
View
Full Document
 Spring '11
 NIL
 Algorithms, Data Structures, random numbers

Click to edit the document details