Reputation: 1
A professor claims that the order in which a fixed set of elements is inserted into an AVL tree does not matter—the same AVL tree results every time.
Give a small example that proves that the professor is wrong.
Upvotes: 0
Views: 744
Reputation: 27
As a trivial example consider the set with elements 1 & 2. Insert 1 then 2 and the root is 1 with 2 as a right child. Insert 2 then 1 and the root is 2 with 1 as the left child.
You will get an AVL tree every time but elements can be in different locations based on the order they were inserted.
Correct me if im wrong
Upvotes: 1