Chapter 22

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

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

11

exponential time

An algorithm with the O(cn) time complexity. As the input size increases, the time for the exponential algorithm grows exponentially. The exponential algorithms are not practical for large input size.

logarithmic time

An algorithm with the O(log n) time complexity

quadratic time

An algorithm with the O(n2) time complexity

worst-case input

An input that results in the longest execution time

best-case input

An input that results in the shortest execution time

Attempts to determine the average amount of time among all possible inputs of the same size

Average-case analysis

Which of the following complexity is O(nlogn)? A. 300n + 400n*n B. 23nlogn + 50 C. 45n + 45nlogn + 503 D. n*n*n + nlogn

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

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.

Backtracking

Input that results in the shortest execution time

Best-case input

Why is the analysis often for the worst case?

Best-case is not representative. 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. 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.

Theoretical approach for analyzing the performance of an algorithm. It estimates how fast an algorithm's execution time increases as the input size increases, which enables you to compare two algorithms by examining their growth rates.

Big-O Notation

Big O notation

Comparing algorithms by examining their growth rates. This notation allows you to ignore constants and smaller terms while focusing on the dominating terms.

Complexity is O(1), which is independent from the input size

Constant time

average-case analysis

Determine the average amount of time among all possible input of the same size.

divide-and-conquer approach

Divides the problem into subproblems, solves the subproblems, then combines the solutions of the subproblems to obtain the solution for the entire problem.

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.

Dynamic programming

Complexity is O(2^n)

Exponential time

convex hull

Given a set of points, this is the smallest convex polygon that encloses all these points.

space complexity

Is the analysis on the space used for the algorithm.

time complexity

Is the analysis on the time used for the algorithm.

dynamic programming 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 is to solve each subproblem only once and store the results for subproblems for later use to avoid redundant computing of the subproblems.

Complexity is O(n)

Linear time

Complexity is O(logn)

Logarithm time

growth rate

Measures how fast the time complexity of an algorithm grows as the input size grows.

All prime numbers less than or equal to n can be found in

O((n√n) / logn) time.

The time complexity for the Towers of Honoi algorithm in the text is

O(2^n)

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

O(2^n)

The time complexity for the Euclid?s algorithm is

O(logn)

The time complexity for the Fibonacci algorithm using the dynamic programming approach is

O(n)

The time complexity for the Sieve of Eratosthenes algorithm is

O(n^(1.5)/logn)

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

O(n^2)

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

O(n^2)

Complexity is O(n^2)

Quadratic Time

brute force

Refers to an algorithmic approach that solves a problem in the simplest or most direct or obvious way.

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

Measures the amount of memory space used by an algorithm

Space complexity

constant time

The Big O notation estimates the execution time of an algorithm in relation to the input size. If the time is not related to the input size, the notation is O(1)

A measure of execution time using the Big-O notation

Time Complexity

Input that results in the longest execution time

Worst-case input

The Eight Queens problem can be solved using

backtracking

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

best-case input

O(1) is

constant time

On an average, linear search searches

half of the list

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

the ceiling of (n - 5) / 3

Analyzing algorithm efficiency is

to estimate their growth function.

You can be assured that the algorithm will never be slower than the

worst case input


संबंधित स्टडी सेट्स

SPK Chapter 11, SPC 205 Ch. 11 Outlining the Speech, Chapter 11 - Outlining the Speech, Chapter 11 - Outlining the Speech

View Set

Título Preliminar Constitución Española

View Set

Final Exam Review - Managerial Economics II

View Set

International Business - Chapter 7

View Set

NSG 170 Test Two (Thermoregulation)

View Set

1- Health and Accident Insurance

View Set

51-102 THE CPA'S PROFESSIONAL RESPONSIBILITIES

View Set