1.6 Algorithm efficiency - key terms and concepts

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

S

- represents the number of fixed-size memory units used by the algorithm for an input of size N

input

A best case or worst case scenario describes contents of the algorithm's ------ data only.

Algorithm

An --------- describes the method to solve a computational problem

k

An algorithm to find the maximum number in a list will have a space complexity of S(N) = N + k, but an auxiliary space complexity of S(N) = -, where k is a constant.

best case

An algorithm's ---- ----- is the scenario where the algorithm does the minimum possible number of operations.

worst case

An algorithm's ----- ----- is the scenario where the algorithm does the maximum possible number of operations

space complexity

An algorithm's ----- ----------- is a function, S(N), that represents the number of fixed-size memory units used by the algorithm for an input of size N.

runtime complexity

An algorithm's ------- ----------- is a function, T(N), that represents the number of constant time operations performed by the algorithm on an input of size N.

auxiliary space complexity

An algorithm's --------- ----- ---------- is the space complexity not including the input data.

best and worst

Because an algorithm's runtime may vary significantly based on the input data, a common approach is to identify ----and ----- case scenarios.

input size

In the T(N) runtime complexity function what does N represent?

constant time operations

In the T(N) runtime complexity function what does T represent?

Worst case (The worst case is when no items in the list are less than value. All array elements are compared against value, then value is returned.)

No items in the list are less than value.

efficient

Programmers and computer scientists should use or write -------- algorithms

input and memory

Space complexity includes the ----- data and additional ------ allocated by the algorithm

constant

T(N) represents the number of -------- time operations performed by the algorithm on an input of size N

neither best or worst case (About half of the list items need to be analyzed in this scenario, which is neither the best nor worst case)

The first half of the list has elements greater than value and the second half has elements less than value.

Best case (The best case is when the first item in the list is less than value. The algorithm returns after 1 comparison)

The first item in the list is less than value.

N

The input data size must remain a variable -

memory

The space complexity of an algorithm that duplicates a list of numbers is S(N) = 2N + k, where k is a constant representing ------ used for things like the loop counter and list pointers.

False (An algorithm can have the same best and worst case, in which case the algorithm always does the same number of operations regardless of input data)

True or False: An algorithm's best and worst case scenarios are always different

True (Runtime and space complexity analysis, discussed below, provide a mathematical way to compare algorithm efficiency)

True or False: Computational complexity analysis allows the efficiency of algorithms to be compared.

False (Although runtime and memory usage are the most common, computational complexity can include other factors, such as network communication.)

True or False: Runtime and memory usage are the only two resources making up computational complexity.

False (Two different algorithms can produce the same result in various ways and may have different computational complexities)

True or False: Two different algorithms that produce the same result have the same computational complexity.

False (The variable value N cannot be replaced with a constant of 0 to describe a best case scenario. A best case scenario must describe the contents of the data being processed)

True or False: the linear search algorithm's best case scenario is when N = 0.

B (In the best case, the input list contains only odd numbers and the output size is 0, whether the list has 10 odd numbers or 1000 odd numbers. A constant output size of zero corresponds to an auxiliary space complexity of k)

What is the best case auxiliary space complexity of GetEvens if N is the list's size and k is a constant? A. S(N) = N + k B. S(N) = k

listSize (If all items in the input list were even, then the returned list would have the same size.)

What is the maximum possible size of the returned list? listSize or listSize/2

C (If the input list doesn't have any even numbers, then the returned list will be empty.)

What is the minimum possible size of the returned list? A. listSize / 2 B. 1 C. 0

T(N)

What is the runtime complexity function?

S(N)

What is the space complexity function?

A (In the worst case, all items from the input list are added to the returned list. As the input size N increases, the output size increases to match.)

What is the worst case auxiliary space complexity of GetEvens if N is the list's size and k is a constant? A. S(N) = N + k B. S(N) = k

algorithm efficiency

is typically measured by the algorithm's computational complexity

Complexity analysis

is used to identify and avoid using algorithms with long runtimes or high memory usage

Computational complexity

the amount of resources used by the algorithm is called...

runtime and memory

the most common resources considered are the -------- and ------- usage


Kaugnay na mga set ng pag-aaral

16. Vicarious Liability (31 2-341)

View Set

U.S. History 2 Kennedy and the Cold War Quiz

View Set

Midterm Business Ethics & Stakeholder Management CH 1-4

View Set

Experimental Psychology Chapter 2

View Set

Euro Unit 1 MC - Chapters 2, 3, & 4

View Set

Legal environment of business Exam 2

View Set