{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# examKEY - COP 3530 Summer 2002 Midterm Exam KEY Name 100...

This preview shows pages 1–4. Sign up to view the full content.

1. (20 points) Shown below is a BST which has become unbalanced after a series of insertions and deletions. Rebalance the BST using the DSW algorithm. Clearly show the following in your answer: The initial backbone. The values of n and m as defined by the algorithm. The initial set of rotations (those which occur outside of the loop in the DSW algorithm). Show the rotations performed in each iteration of the algorithm leading to the perfectly balanced BST. Backbone is: Value of n = 9, m = 1 2 1 n 2 - + ) ( log = 2 3 -1 = 7 Number of initial rotations is given by n – m = 2 Thus, first rotate 18 about 15 and 32 about 22 1 COP 3530 – Summer 2002 Midterm Exam June 17, 2002 Name: 100 points total 3 2 1 3 1 4 6 5 4 KEY 1 1 2 3 3 4 4 5 6 1 1 2 3 3 4 4 5 6 1 1 2 3 3 5 4 5 4 7 5 0 6 9

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Backbone after initial 2 rotations First iteration causes m = 7/2 = 3 rotations 32 about 18, 45 about 35, and 50 about 47. Next iteration sets m = 3/2 = 1 rotation, 45 about 32 to produce the final perfectly balance tree. 2. (15 points) 2 1 2 1 3 3 5 4 5 4 7 5 0 6 9 3 5 4 5 1 2 1 3 4 7 5 0 6 9
Shown below is a splay tree. Assuming that a get(34) operation is performed on this tree. (a) Identify the splay node and its level in the tree, and (b) perform the splay operation and redraw the tree in the configuration that will result after the splay operation is completed. The search for 34 is unsuccessful, thus 31 becomes the splay node. The splay node is

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 9

examKEY - COP 3530 Summer 2002 Midterm Exam KEY Name 100...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online