Sean Bollin
Sean Bollin

Reputation: 910

Find the node whose deletion requires 2 rotations?

Draw an AVL tree with 8 keys 1,...,8.

For the tree find a node whose deletion requires 2 rotations.

When I draw the tree I don't see any nodes where a deletion would require 2 rotations. Am I wrong?

an AVL tree

Upvotes: 0

Views: 49

Answers (1)

alw
alw

Reputation: 56

An AVL tree does not have to be unique given a certain set of keys for example, the same set of keys could generate an AVL tree with 8 at 7's current position with a left pointer to 7. Considering this tree and looking at http://en.wikipedia.org/wiki/AVL_tree#Insertion, you should be able to find a node such that deleting it would lead to a Right Left case.

Upvotes: 2

Related Questions