Chapter 22 CSC 216

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

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

A. 11

Why is the analysis often for the worst case?

A. Best-case is not representative. B. Worst-case is not representative, but worst-case analysis is very useful. You can show that the algorithm will never be slower than the worst-case. C. Average-case analysis is ideal, but difficult to perform, because it is hard to determine the relative probabilities and distributions of various input instances for many problems.

______________ 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

The time complexity for the algorithm using the dynamic programming approach is ________.

A. O(n)

O(1) is ________.

A. constant time

Which of the following complexity is O(nlogn)?

B. 23nlogn + 50 C. 45n + 45nlogn + 503

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

B. Dynamic programming

The time complexity for the Sieve of Eratosthenes algorithm is ________.

B. O(n^(1.5)/logn)

The time complexity for the insertion sort algorithm in the text is ________.

B. O(n^2)

The time complexity for the selection sort algorithm in the text is ________

B. O(n^2)

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

B. O(nlogn)

The time complexity for the the closest pair of points problem using divide-and-conquer is ________.

B. O(nlogn)

On an average, linear search searches

B. half of the list

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

C. O(logn)

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.

D. Backtracking

The time complexity for the Towers of Hanoi algorithm in the text is ________.

D. O(2^n)

The time complexity for the recursive Fibonacci algorithm in the text is ________

D. O(2^n)

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

D. O(n^2)

What is the number of iterations in the following loop: int count = 5; while (count < n) { count = count + 3; }

E. the ceiling of (n - 5) / 3

An input that results in the shortest execution time is called the _____________

best-case input

Analyzing algorithm efficiency is ________.

to estimate their growth function


Ensembles d'études connexes

Chapter 2 Psychological Research

View Set

Classification of Tissues Exercise 6 Pre lab Quiz

View Set

Sociology, Chapter 1-16 (megansanny)

View Set

MAO ESSAY PLAN- How far do you agree that the consolidation of communist rule in China 1949-56 can be explained more by support of the CCP than by the use of intimidation?

View Set

Chapter 24, Exsc 223 chapter 24, Final for Anatomy T/F, EXSC 223 Final Exam Review, EXSC223 Exam 1, EXSC 223 Exam 2, EXSC223 Exam 3

View Set

Le Italiane e la Storia - Maria Pia Casalena

View Set