Professional Documents
Culture Documents
Chapter 10 Practice Test
Chapter 10 Practice Test
INSTRUCTIONS: Answer each question below. Once you finish taking the test, check
the answers provided in the Answer Key at the end of this test.
1. Which of the functions f(x) = 100x, g(x) = 10x2, or h(x) = (1.02)x will eventually be
the largest?
A: f(x)
B: g(x)
C: h(x)
D: cannot be determined
3.
Suppose f(n) is an eventually non-decreasing function where f(1) = d, f(n) = af( )
+ cnk, if n > 1 and n = bm, where m is a positive integer, b 2, k 0 are constant
integers, and a > 0, c > 0, and d 0 are constants. If a < bk then f(n) is
A: (nk)
B: (nklg n)
C: (nlogba)
D: none of the above
7. Let n 1 then n! is
A: (n2)
B: (n)
C: (nlg n)
D: none of the above
9. Suppose that f(n) is O(n2) and g(n) is O(n3), then f(n) + g(n) is
A: O(n)
B: O(n2)
C: O(n3)
D: none of the above
10. Define the relation R on the set of nonnegative real valued functions by f R g if
For exercises 11 through 13, Let L be the list of elements 35, 45, 15, 20, 95, 50.
Suppose that sequential search is used.
For exercises 14 through 16, Let L be the list of elements 35, 45, 55, 60, 75, 95, 100.
Suppose that binary search is used.
For exercises 17 through 19, Let L be the list of elements 35, 45, 15, 20, 95, 50.
Suppose that selection sort is used.
18. How many comparisons are required to place the first element in the "sorted"
list?
A: 3
B: 5
C: 7
D: none of the above
19. How many comparisons are required to place the third element in the "sorted"
list?
A: 3
B: 5
C: 7
For exercises 20 through 22, Let L be the list of elements 15, 20, 45, 30, 95, 50.
Suppose that insertion sort is used and the first two keys are in order.
20. To move 45 to the correct position, how many comparisons are required?
A: 1
B: 3
C: 5
D: none of the above
21. Now assuming the first three keys are in order, how many comparisons are
required to move 30 to the correct position?
A: 2
B: 3
C: 5
D: none of the above
22. When the first five keys are in order, to place 50 will require how many
comparisons?
A: 2
B: 3
C: 5
D: none of the above
For exercises 23 through 25, let L1 be the list of elements 2, 4, 7, 8, 18 and let L2 be
the list of elements 3, 5, 9, 11, 20, 22, 25. Suppose that merge sort is used.
23. How many comparisons are required to place the first element in the "sorted"
list.
A: 1
B: 2
C: 3
D: none of the above
25. How many comparisons are required to place the second element in the "sorted"
list.
A: 1
B: 2
C: 3
D: none of the above
26. In the worst case, which of the following sorts is not O(n2)?
A: insertion
B: selection
C: bubble
D: none of the above
30. If A is a 2x4 matrix, B is a 4x5 matrix, C is a 5x3 matrix, and D is a 3x7 matrix,
what is the optimal number of scalar multiplications required to compute
ABCD?
A: 105
B: 112
C: 144
D: none of the above
1. C 2. D 3. A 4. B 5. C 6. A 7. C 8. A 9. C 10. A
11. C 12. B 13. D 14. C 15. C 16. D 17. C 18. B 19. A 20. A
21. A 22. A 23. A 24. B 25. B 26. D 27. A 28. B 29. C 30. B