Chapter 22 Flashcards

1
Q

Analyzing algorithm efficiency is ________.

	A.
to measure their actual execution time
	B.
to estimate their execution time
	C.
to estimate their growth function
A

C.

to estimate their growth function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

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

A.

best-case input

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

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
A

B.

half of the list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

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
A

E.

the ceiling of (n - 5) / 3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

For a sorted list of 1024 elements, a binary search takes at most _______ comparisons.

	A.
11
	B.
100
	C.
512
	D.
6
A

A.

11

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
O(1) is \_\_\_\_\_\_\_\_.
	A.
constant time
	B.
logarithmic time
	C.
linear time
	D.
log-linear time
A

A.

constant time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

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)
A

D.

O(2^n)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

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)
A

B.

O(n^2)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

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)
A

B.

O(n^2)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

______________ 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
A

B.

Dynamic programming

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

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)
A

D.

O(2^n)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

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

A.

O(n)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

The time complexity for the Euclid?s algorithm is ________.

	A.
O(n)
	B.
O(n^2)
	C.
O(logn)
	D.
O(2^n)
A

C.

O(logn)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

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)
A

B.

O(n^(1.5)/logn)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

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)
A

B.

O(nlogn)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

______________ approach divides the problem into subproblems, solves the subproblems, then combines the solutions of the subproblems to obtain the solution for the entire problem. Unlike the ________ approach, the subproblems in the divide-and-conquer approach don?t overlap. A subproblem is like the original problem with a smaller size, so you can apply recursion to solve the problem.

	A.
Divide-and-conquer/dynamic programming
	B.
Dynamic programming/divide-and-conquer
	C.
Brutal-force/divide-and-conquer
	D.
Backtracking/dynamic programming
A

A.

Divide-and-conquer/dynamic programming

17
Q

The ________ approach searches for a candidate solution incrementally, abandoning that option as soon as it determines that the candidate cannot possibly be a valid solution, and then looks for a new candidate.

	A.
Divide-and-conquer
	B.
Dynamic programming
	C.
Brutal-force
	D.
Backtracking
A

D.

Backtracking

18
Q

The gift-wrapping algorithm for finding a convex hull takes ______________ time.

	A.
O(n)
	B.
O(nlogn)
	C.
O(logn)
	D.
O(n^2)
A

D.

O(n^2)

19
Q

The Graham?s algorithm for finding a convex hull takes ______________ time.

	A.
O(n)
	B.
O(nlogn)
	C.
O(logn)
	D.
O(n^2)
A

B.

O(nlogn)