Chapter 22 Flashcards
Analyzing algorithm efficiency is ________.
A. to measure their actual execution time B. to estimate their execution time C. to estimate their growth function
C.
to estimate their growth function
An input that results in the shortest execution time is called the _____________.
A. best-case input B. worst-case input C. average-case input
A.
best-case input
On an average, linear search searches
A. the whole list B. half of the list C. just one element in the list D. one fourth of the list
B.
half of the list
What is the number of iterations in the following loop:
intcount =5; while(count < n) { count = count +3; } A. n - 5 B. n - 3 C. n / 3 - 1 D. (n - 5) / 3 E. the ceiling of (n - 5) / 3
E.
the ceiling of (n - 5) / 3
For a sorted list of 1024 elements, a binary search takes at most _______ comparisons.
A. 11 B. 100 C. 512 D. 6
A.
11
O(1) is \_\_\_\_\_\_\_\_. A. constant time B. logarithmic time C. linear time D. log-linear time
A.
constant time
The time complexity for the Towers of Hanoi algorithm in the text is ________.
A. O(n) B. O(n^2) C. O(n^3) D. O(2^n)
D.
O(2^n)
The time complexity for the selection sort algorithm in the text is ________.
A. O(nlogn) B. O(n^2) C. O(logn) D. O(2^n)
B.
O(n^2)
The time complexity for the insertion sort algorithm in the text is ________.
A. O(nlogn) B. O(n^2) C. O(logn) D. O(2^n)
B.
O(n^2)
______________ approach is the process of solving subproblems, then combining the solutions of the subproblems to obtain an overall solution. This naturally leads to a recursive solution. However, it would be inefficient to use recursion, because the subproblems overlap. The key idea behind dynamic programming is to solve each subproblem only once and store the results for subproblems for later use to avoid redundant computing of the subproblems.
A. Divide-and-conquer B. Dynamic programming C. Brutal-force D. Backtracking
B.
Dynamic programming
The time complexity for the recursive Fibonacci algorithm in the text is ________.
A. O(nlogn) B. O(n^2) C. O(logn) D. O(2^n)
D.
O(2^n)
The time complexity for the algorithm using the dynamic programming approach is ________.
A. O(n) B. O(n^2) C. O(logn) D. O(2^n)
A.
O(n)
The time complexity for the Euclid?s algorithm is ________.
A. O(n) B. O(n^2) C. O(logn) D. O(2^n)
C.
O(logn)
The time complexity for the Sieve of Eratosthenes algorithm is ________.
A. O(n) B. O(n^(1.5)/logn) C. O(logn) D. O(2^n)
B.
O(n^(1.5)/logn)
The time complexity for the the closest pair of points problem using divide-and-conquer is ________.
A. O(n) B. O(nlogn) C. O(logn) D. O(2^n)
B.
O(nlogn)