174k views
5 votes
2 Consider the sequence of keys (5,16,22,45,2,10,18,30,50,12,1). Draw the result of inserting entries with these keys (in the given order) into a. An initially empty (2,4) tree. b. An initially empty red-black tree.

1 Answer

1 vote

Answer:

A) (2,4) tree

  • Insertion of key 45 makes key unbalanced and this is because it violates the 2,4 tree so we split the node
  • insertion of key 10 makes key unbalanced and this is because it violates the 2,4 tree so we split the node

B) Red-black tree

Step-by-step explanation:

The diagrams for the solutions are attached showing the results of inserting entries

2 Consider the sequence of keys (5,16,22,45,2,10,18,30,50,12,1). Draw the result of-example-1
2 Consider the sequence of keys (5,16,22,45,2,10,18,30,50,12,1). Draw the result of-example-2
2 Consider the sequence of keys (5,16,22,45,2,10,18,30,50,12,1). Draw the result of-example-3
User Pretzel
by
3.6k points