hw3 Sols
hw3 Sols
IMPORTANT:
• Upload this PDF with your answers to Gradescope by 11:59pm on Wednesday Oct 04,
2017.
• Plagiarism: Homework may be discussed with other students, but all homework is to be
completed individually.
• You have to use this PDF for all of your answers.
For your information:
• Graded out of 100 points; 4 questions total
• Rough time estimate: ≈1-4 hours (0.5-1 hours for each question)
Revision : 2017/10/22 09:35
1
15-445/645 (Fall 2017) Homework 3 Page 2 of 10
(b) Answer the following questions about Figure 1. Suppose we insert keys 30, 21, 12, 42,
31 in order.
i. [5 points] Which key will cause the first split?
2 30 21 2 12 2 42 2 31 2 None of the above
ii. [5 points] Which key will first cause the directory to double in size?
2 30 2 21 2 12 42 2 31 2 None of the above
(c) Start from the hash table of Figure 1. Consider the result after deleting keys 18, 14 in
order.
i. [5 points] How many buckets will remain?
2 0 2 1 2 3 2 4 2 5 2 None of the above
Question 1 continues. . .
15-445/645 (Fall 2017) Homework 3 Page 3 of 10
ii. [5 points] What is the local depth of the bucket containing key 2?
2 0 1 2 2 3 2 4 2 5 2 None of the above
Solution: Either (i)3 (ii)2, or (i)2 (ii)1 is correct.
Homework 3 continues. . .
15-445/645 (Fall 2017) Homework 3 Page 4 of 10
(c) [5 points] What is the largest key less than 25 whose insertion will cause a split?
Solution: 23
(d) [10 points] Starting from the hash table of Figure 2, plot the final hash table, after in-
serting 13, 19, 20. Remember to indicate the new hash function (if any), and to update the
“Next” pointer, if needed. You may use the draw.io template, at:
http://cmudb.io/fall2017-hw3-q2
Solution: see below
Question 2 continues. . .
15-445/645 (Fall 2017) Homework 3 Page 5 of 10
Homework 3 continues. . .
15-445/645 (Fall 2017) Homework 3 Page 6 of 10
(b) [5 points] Consider the B+ tree in Figure 3, what is the minimum number of pointers to
be followed to satisfy the query: Get all records with key greater than 11 and less than
20?
Figure 3: B+ Tree
Solution: 5
(c) Consider the B+ tree in Figure 4 of order d = 2 and height h = 2 levels. Please make the
following assumptions:
• With respect to “≥”, follow the convention used in the textbook, and in Figure 4, that
is, the left pointer is for <, the right one for ≥.
• In case of underflow, if you can borrow from both siblings, choose the one on the
right.
For all questions below, use the standard B+ tree algorithm given in the slides and the
textbook (on insertions: 2-to-1 split, no deferred splits; on deletions: no underflowing
pages). For your drawing convenience, you may use the draw.io template, at:
http://cmudb.io/fall2017-hw3-q3
In all cases, start from the B+ tree of Figure 4.
Question 3 continues. . .
15-445/645 (Fall 2017) Homework 3 Page 7 of 10
ii)
or
iii)
iv)
Question 3 continues. . .
15-445/645 (Fall 2017) Homework 3 Page 8 of 10
v)
Homework 3 continues. . .
15-445/645 (Fall 2017) Homework 3 Page 9 of 10
(a) [6 points] Consider the skip list in Figure 5. Suppose we want to insert key 35. Which
of the following node(s) might directly point to the new node? Select all that apply.
3 2 6 2 8 15 21 2 37 2 50 2 Nil 2 None of the above
(b) [6 points] Consider the radix tree in Figure 6. Is it a valid radix tree? If yes, draw the
tree after inserting the new word ”approve”. Else, draw the valid radix tree with existing
words. You may use the draw.io template at:
http://cmudb.io/fall2017-hw3-q4
Solution: Not valid
Question 4 continues. . .
15-445/645 (Fall 2017) Homework 3 Page 10 of 10
End of Homework 3