This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: CSE 2320 Name ________________________________ Test 1 Summer 2004 Student ID # ___________________________ Multiple Choice. Write your answer to the LEFT of each problem. 4 points each 1. Which of the following sorts uses time beyond O(n lg n) in the average case? A. heapsort B. insertion C. merge D. quick 2. Which sort treats keys as several digits and uses a counting sort for each position? A. counting B. insertion C. merge D. radix 3. Which of the following is an accurate statement? A. Binary search is a good way to count inversions. B. Mergesort can count the inversions in a permutation using (n log n) worstcase time. C. Mergesort can count the inversions in a permutation using (n 2 ) worstcase time. D. The decisiontree model indicates that the number of inversions in a permutation is bounded above by n log n. 4. Which function is in both (2 n ) and O(3 n ), but is not in (2 n ) or (3 n )? A. 2 n + n 2 B. 3 n n 2 C. 2.5 n D. ln n 5. Which recurrence describes the time used by mergesort? A. T n ( ) = T n 2 ( ) + n B. T n ( ) = 2 T n 2 ( ) + n C. T n ( ) = T n 1 ( ) + n 1 D. T n ( ) = T n 2 ( ) +1 6. Which of the following sorts is stable? A. heapsort B. insertion C. quick D. shell 7. What is the value of H 3 ? A. lg 3 B. 1 3 C. 11 6 D. 3 8. The time for the following code is in which set? for (i=0; i<n; i++) for (j=0; j<n; j++) { c[i][j] = 0; for (k=0; k<n; k++) c[i][j] += a[i][k]*b[k][j]; } A. (n) B. (n log n) C. (n 2 ) D. (n 3 ) 9. Let f(n) and g(n) be asymptotically positive functions. Which of the following is true? A. f(n) = (f(n/2)) B. f(n) = O(g(n)) implies g(n) = (f(n)) C. f(n) = O(g(n)) implies g(n) = O(f(n)) D. f(n) + g(n) = (min(f(n),g(n)) 10. After performing P ARTITION , the pivot will be at which position? A. its final position when using Q UICKSORT on the entire array. B. the first element of the subarray. C. the last element of the subarray. D. the median position of the subarray. Long Answer 1. Prove that if 1 f ( n ) W 1 g ( n ) ae then f ( n ) O g ( n ) ( ). 10 points 2. Use the substitution method to show that T n ( ) = 2 T n 4 ( ) +1 is in n ( ) . 15 points 3. Use the recursiontree method to show that T n ( ) = 2 T n 4 ( ) +1 is in n ( ) . 15 points 4. Demonstrate P ARTITION on the following array. 10 points 9 3 1 8 5 6 2 7 4 5. Perform B UILDM AXH EAP . 10 points 11 6 1 10 8 4 3 2 5 1 2 3 4 5 6 7 8 9 9 10 7 11 1 2 3 4 5 6 7 8 9 10 11 CSE 2320 Name ________________________________ Test 2 Summer 2004 Student ID # ___________________________ Multiple Choice. Write the letter of your answer to the LEFT of each problem. 4 points each Problems 1 and 2 refer to the following hash table whose keys are stored by linear probing using h(key, i) = (key + i) % 13....
View
Full
Document
This note was uploaded on 03/25/2012 for the course CSE 2320 taught by Professor Bobweems during the Spring '12 term at UT Arlington.
 Spring '12
 BOBWEEMS
 Sort

Click to edit the document details