Name: Userid: CMSC 341 Fall 2018 Homework 6 ------------------------------------------------------------------- Question A (15 points) ------------------------------------------------------------------- [Adapted from problem R-9.8 in textbook] Hash the values 94, 11, 39, 20, 16, 5, 12, 44, 13, 88 and 23 into a hash table with 11 slots. Handle collisions by linear probing. Use the hash function: h(i) = (3 * i + 5) % 11 Type in each key on the same line as the index of the slot where it is eventually inserted. YOUR ANSWER TO QUESTION A: 0: 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: ------------------------------------------------------------------- Question B (20 points) ------------------------------------------------------------------- [Adapted from problem R-9.10 in textbook] Repeat Question A using double hashing instead of linear probing. Use the secondary hash function h'(k) = 7 - (k % 7). YOUR ANSWER TO QUESTION B: 0: 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: ------------------------------------------------------------------- Question C (35 points total) ------------------------------------------------------------------- We want to support the operations Insert(), Find() and Max() for a program that uses n Insert(), n Find() and 15 Max() operations. These operations can be performed in any order. The Max() operation simply reports the maximum valued stored in the data structure at the time of the call. 1. (5 points) Suppose that we use a red-black tree to support this program. What is the asymptotic worst case running time for n Insert(), n Find() and 15 Max() operations? (a) O(n) (b) O(n log n) (c) O(n^2) (d) O(n^2 log n) (e) O(n^3) Answer: 2. (5 points) BRIEFLY explain your choice above. 3. (5 points) Suppose that we use a binary max heap to support this program. What is the asymptotic worst case running time for n Insert(), n Find() and 15 Max() operations? (a) O(n) (b) O(n log n) (c) O(n^2) (d) O(n^2 log n) (e) O(n^3) Answer: 4. (5 points) BRIEFLY explain your choice above. 5. (5 points) Suppose that we use a hash table with a "good" hash function to support this program. What is the asymptotic "average" running time for n Insert(), n Find() and 15 Max() operations? (a) O(n) (b) O(n log n) (c) O(n^2) (d) O(n^2 log n) (e) O(n^3) Answer: 6. (5 points) BRIEFLY explain your choice above. 7. (5 points) Which of these three data structures would you pick to support n Insert(), n Find() and 15 Max() operations? Briefly justify your answer.