



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




General Rules (Read): This exam is closed book and closed notes. If you have a question, please raise your hand. Total point value is 100 points. Answer True/False questions by circling the True or False at the end of the question. Answer essay questions concisely using 1 or 2 sentences. Longer answers are not necessary and are discouraged. WRITE NEATLY. If we cannot understand your answer, we will not grade it (i.e., 0 credit).
a. What is the big O notation for heapsort? Answer: O(nlog(n)) b. Heaps are balanced trees. True/False. Answer: True c. A heap is a binary search tree. True/False. Answer: False d. List the order nodes are traversed in an depth-search traversal of the tree Answer: 8,9,11,13,10,12,14 One possible traversal e. List the order nodes are traversed in a breadth-first traversal of the tree Answer: 8, 9, 10, 11, 13, 12, 14 One possible traversal f. (4 pts) Draw the heap that would result from inserting 5 in the above heap. g. (4 pts) Draw the heap that would result by deleting 8 from the original heap.
True/False. Answer: True b. (2 pts) What is the load factor? i. Number of entries in the hash table divided by table size ii. Maximum number of entries that can be placed in the table iii. The load generated by the multiplicative congruency method iv. None of the above. Answer: i c. (2 pts) The hashCode method for a class always returns the number 14. Is this a valid hashCode method for the class? True/False. Answer: True d. (2 pts) Hashing is efficient for a load factor that is less than: i. 99% ii. 90% iii. 80% iv. None of the above. Answer: ii e. (4 pts) Mentioned two properties of a good hash function? Notice we are not asking about the properties of the Java hashCode method. Answer: Any two valid ones. Possible ones:
LowestCost 3 0 ∞ 2 5 5 Predecessor D none none B A B
iv. (14 pts) decreasingOrder – Implement a method named decreasingOrder. It returns an array with the data elements of the tree in decreasing order.