CS302 Midterm Exam - October 13, 2015 - Page Two


Question 2

What are the running times of each of the following? Use the answer sheet for this. In the questions that have both m and n, assume that m is less than n, and make sure that your answer is as precise as possible. For example, if something is O(mn), then it is true that it is also O(n2); however, in that case O(mn) is the correct answer.

Question 3

Part A: Which of the following vectors represent binary heaps? Part B: Give me the vector version of the binary heap that results when you call Push(3) on the following heap: { 9, 23, 11, 57, 38, 17, 12, 86, 88, 80 }

Part C: Give me the vector version of the binary heap that results when you call Pop() on the following heap: { 6, 17, 45, 21, 26, 51, 52, 74, 67, 89 }