Unit 1 Flashcards

1
Q

To determine the best algorithms to use, computer scientists analyze the complexity of the algorithm by comparing two algorithms at the blank level

A

idea

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

To analyze algorithm complexity, computer scientists use pragmatic tools such as blank, blank and blank notations to formally measure how fast a program or algorithm runs.

A

big-O, Theta, and Omega

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

An blank is a step-by-step method for solving a problem. A description of an algorithm specifies the input to the problem, the output to the problem, and the sequence of steps to be followed to obtain the output from the input.

A

algorithm

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

Algorithms are often described in blank, which is a detailed yet readable description of what an algorithm must do, expressed in a formally-styled natural language rather than in a programming language.

A

pseudocode

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

An important type of step in an algorithm is an blank, in which a variable is given a value.

A

assignment

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

An assignment operator is denoted by:

blank

A

x := y

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

The output of an algorithm is specified by a blank statement.

A

return

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

A description of an algorithm starts with the blank.

A

name of the algorithm

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

The name is followed by a blank of what the algorithm computes

A

description

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

A description of an algorithm usually includes what five steps:

A

A name for the algorithm
A brief description of the task performed by the algorithm
A description of the input
A description of the output
A sequence of steps to follow

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

An blank tests a condition, and executes one or more instructions if the condition evaluates to true.

A

if-statement

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

In a blank, a condition and instruction appear on the same line.

A

single line if-statement

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

What is the notation for an if-statement?

A

If (x = 5), y := 7

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

An if-statement can also be followed by a blank of indented operations with a final end-if statement.

If ( condition )
Step 1
Step 2
. . .
Step n
End-if

A

sequence

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

An blank tests a condition, executes one or more instructions if the condition evaluates to true, and executes a different set of instructions if the condition evaluates to false

A

if-else-statement

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

Name the pattern for if-else statement

A

If ( condition )
One or more steps
Else
One or more steps
End-if

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

An if-then statement tests a blank and executes one or more steps if the condition is true. An if-else statement tests the condition, and executes one or more instructions if the condition is true, and another instruction or set of instructions if it is false.

A

condition

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

The structure of the if-then statement in pseudocode when there is only one step to execute when the condition is true is:
blank

A

If(condition), step

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

When multiple steps should be performed upon a true condition, the steps are indented and the end of the list of steps is noted with an blank statement:

A

End-if

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

The if-else statement in pseudocode is formatted in what format:

A

If (condition)
One or more steps
Else
One or more steps
End-if

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

The multiple step if statement in pseudocode is formatted in what format:

A

If (condition)
Step 1
Step 2

Step n
End-if

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

When needed, if-then and if-else statements can be blank

A

nested.

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

There are blank regarding how many if-then or if-else statements can be placed under another if-then or if-else statement.

A

no limitations

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

An blank is a process where a set of instructions or structures are repeated in a sequence a specified number of times or until a condition is met.

A

iteration

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

To control the iterations, blank use an index or a counter and a variable that counts how many times a step or a block of steps executes.

A

for-loops

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

Blank structures provide a means of specifying a sequence of steps that are to be repeated.

A

Looping

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

There are two common types of loops: blank and blank.

A

for-loops and while-loops

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

In a blank, a block of instructions is executed a fixed number of times as specified in the first line of the for-loop, which defines an index, a starting value for the index, and a final value for the index.

A

for-loop

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

Each repetition of the block of instructions inside the for-loop is called an blank

A

iteration.

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

The index is initially assigned a value equal to the blank, and is incremented just before the next iteration begins. The final iteration of the for-loop happens when the index reaches the final value.

A

starting value

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

Give the syntax for a for loop

A

For i = s to t
Step 1
Step 2
. . .
Step n
End-for

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

For-loops are used when the number of iterations in the loop is blank.

A

known

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

The for-loop iterates blank times.

A

final_value-start_value+1

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

A blank iterates an unknown number of times, ending when a certain condition becomes false.

A

while-loop

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

A while-loop is written as blank:

A

While ( condition )
Step 1
Step 2
. . .
Step n
End-while

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

The blank is an expression that evaluates to true or false. If the expression evaluates to true, then steps 1 through n are performed and the algorithm goes back to the first statement where the condition is re-evaluated. The process continues until the condition evaluates to false, at which point the algorithm proceeds with the next step after the while-loop.

A

condition

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

blank are used when the number of iterations in the loop is unknown and may execute zero or more iterations.

A

While-loops

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

While loops are controlled by a blank. If the blank is true, the loop initiates an iteration otherwise it stops.

A

conditional statement

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

While-loops use the blank syntax in pseudocode:

A

While (condition)
One or more steps
End-while

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

The while-loop iterates blank or blank times until the condition is met.

A

zero or more

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

When a loop exists within another loop, it is called a blank loop

A

nested

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

When loops are nested the blank loop takes control of the number of complete repetitions of the blank loop.

A

outer
inner

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

A blank is a loop that appears within another loop

A

nested loop

43
Q

The nested loop, known as the blank, is treated as a sequence of steps inside the outer loop.

A

inner loop

44
Q

blank can nest in blank, and vice-versa; loops of the same type can also nest.

A

While-loops
for-loops

45
Q

The blank takes control of the number of complete repetitions of the blank.
The first pass of the outer loop triggers the inner loop, which executes to completion.
Then the second pass of the outer loop triggers the inner loop again.
This repeats until the outer loop finishes.

A

outer loop
inner loop

46
Q

To solve a problem an algorithm needs blank

A

resources

47
Q

The primary resources to optimize are blank, the time the algorithm requires to run, and blank, the amount of memory used.

A

time complexity
space complexity

48
Q

The blank depends on the speed of the processing unit, the number of calculations that need to be performed, the number of conditions that need to be evaluated, or the number of iterations to be completed by the loops.

A

time

49
Q

The values of all variables, including the values of the input variables and all other values that will be computed, need to be stored somewhere in the blank of the system—in the RAM, hard drive, or external devices.

A

memory

50
Q

Naturally, a program will take more time and space on larger inputs. For example, a program that sorts a sequence of numbers will take a longer time to sort a long sequence than a short sequence. Therefore, time and space efficiency are measured in terms of the blank

A

input size

51
Q

The way the size of the input is measured varies based on the blank

A

type of problem

52
Q

When sorting numbers, for example, the blank is the number of numbers to be sorted.

A

input size

53
Q

An algorithm that processes a digital image would likely be measured as a function of the blank in the image.

A

number of pixels

54
Q

An algorithm that processes a recorded speech given at a commencement ceremony will likely use the blank as the size of the input.

A

length of the speech

55
Q

The input size for a problem is usually denoted by the variable blank
, and the assessments of the algorithms’ resources needs are denoted in functions of blank that give the best-, worst-, and average-case scenario behavior of the algorithms.

A

n

56
Q

Not all elements of the blank provide equally relevant information about how much more resources an algorithm would need as n grows.

A

complexity functions

57
Q

What is

F[1] :=1
F[2]:=1
For i:=3 to n
F[i] := F[i-1]+F[i- 2]
End-for
Return (F[n])

A

Algorithm Fibonacci-1

58
Q

The choice of blank can heavily influence the efficiency of a solution to a computing problem

A

algorithms

59
Q

Blank is a measure of the resources an algorithm uses.

A

Computational complexity

60
Q

blank measures the time an algorithm needs to complete.

A

Time complexity

61
Q

Blank measures the amount of memory an algorithm uses during its execution

A

Space complexity

62
Q

Programmers commonly seek optimal ways to sort numbers and optimize databases to store data with algorithms that will speed up blank

A

retrieval

63
Q

These operations (e.g., addition, multiplication, comparison) that one would find in a single line of pseudocode, are referred to as blank

A

atomic operations

64
Q

They are called “atomic,” because they cannot be split any further; a computer would evaluate each in one step.

A
65
Q

blank takes longer to complete than addition, as multiple additions need to happen to find the product of two numbers.

A

Multiplication

66
Q

blank is the same as the addition of negated numbers and division is a series of subtractions.

A

Subtraction

67
Q

Blank is a repeated multiplication, so it takes longer to execute

A

Exponentiation

68
Q

At the same time, a blank takes longer to complete than assignments, as they consist of statements that are integrated multiple times.

A

loop

69
Q

As the size of the input grows, blank and blank partake less and less in the total time the algorithm takes to complete because the multiplication and loops dominate the time.

A

addition and assignment statements

70
Q

Each blank has its position in the sequence, and the total number of blank in the sequence is referred to as its size.

A

element

71
Q

Use these guidelines to count the number of atomic operations:

A

Count each assignment as one operation
Multiply the operations in the body of the loop by the number of iterations of the loop
Ignore constant factors; focus on the elements of the functions that grow the fastest

72
Q

Specific features of computing systems, such as blank, are not considered when comparing how the time to complete an algorithm grows as the size of the input grows.

A

processor speed

73
Q

blank is performed to measure the resources (time or space) that an algorithm requires in the worst case.

A

Worst-case analysis

74
Q

The term “worst case” refers to an input that triggers the blank of calculations, thus taking the longest to complete of all other inputs of the same size

A

maximum number

75
Q

The worst-case analysis provides an blank on the resources required by the algorithm.

A

upper bound

76
Q

blank are compared by their average running and best running times.

A

Algorithms

77
Q

blank is used to estimate how much time might be needed in the worst case to guarantee that the algorithm will always finish on time.

A

Worst-case complexity

78
Q

blank and blank are the most used in algorithm analysis.

A

Average performance and worst-case performance

79
Q

the behavior of the complexity function as n grows.

A

asymptotic complexity

80
Q

Any program that doesn’t have loops will have an asymptotic complexity of blank, since the number of instructions it needs is just a constant.

A

1

81
Q

Any program with a single loop which goes from 1 to n will have asymptotic complexity blank since it will do a constant number of instructions before the loop, a constant number of instructions after the loop, and a constant number of instructions within the loop which all run n times.

A

n,

82
Q

This method of searching for a value within an array is called blank. The asymptotic complexity for this algorithm is n due to the single for-loop. Note that this algorithm might not need to go through all n elements of the array to find one; however, in the worst-case scenario when it does (when no elements equals V or the last element of the array equals V), the loop will run n times.

A

linear search.

83
Q

Simple programs can be analyzed by counting the blank of the program.
A single loop over n items yields asymptotic complexity n.

A

nested loops

84
Q

If you have a program that calls a function within a loop and you know the number of atomic operations the called function performs, it is easy to determine the blank of the whole program.

A

number of atomic operations

85
Q

Since you know that f(n) is a function that performs exactly n instructions, you then know that the number of instructions of the whole program is asymptotically blank, as the function is called exactly n times.

A

n2

86
Q

Given a series of for-loops that are sequential, the blank of them determines the asymptotic behavior of the program.

A

slowest

87
Q

blank is a basic mathematical tool for working with functions that we only know up to a constant factor. There are three types of asymptotic notation that are commonly used in algorithmic analysis, O(n) (“big-O”), Ω(n) (“Omega”), and Θ(n) (“Theta”).

A

Asymptotic notation

87
Q

Two nested loops followed by a single loop is asymptotically blank as the nested loops alone, because the nested loops dominate the simple loop.

A

the same

88
Q

Blank—serves as a rough upper bound for functions (disregarding constants and small input values).

A

The big-O notation—O(n)

89
Q

The blank is similar to big-O, except that it provides a lower bound on the growth of a function.

A

Ω notation—Ω(n)—

90
Q

The blank—indicates how the algorithm performs for any case. This is referred to as an average time or random case function and, when possible, gives us a sense of how the algorithm performs in any case. Note that it is often possible to estimate upper and lower bounds, but not average cases especially if there are complex branching in the code.

A

Θ notation—Θ(n)

91
Q

Blank describes the behavior of the complexity function as n grows. Only the terms that grow fastest in a complexity function significantly influences its blank, so they are retained without constant multipliers.

A

Asymptotic complexity

92
Q

To find the asymptotic behavior for the given function, drop the constant factors and keep the terms that blank. For example, in this function: 6n + 4, drop the 4 because it remains constant and the constant multiplier 6.

A

grow the fastest

93
Q

An algorithm without loops has a constant asymptotic complexity of blank, since the number of instructions it needs is just a constant.

A

1

94
Q

Any program with a single loop which goes from 1 to n will have asymptotic complexity blank, since it will do a constant number of instructions before the loop, a constant number of instructions after the loop, and a constant number of instructions within the loop which all run n times.

A

n

95
Q

If you cannot readily decide which one of the terms grows faster, plug in several large values for blank and compare.

A

n

96
Q

A single loop that iterates up to n times has a blank asymptotic complexity.

A

linear

97
Q

The asymptotic complexity of a loop nested in a loop is blank.

A

quadratic

98
Q

The blank is the most common in the context running times/time complexity.

A

big-O notation

99
Q

The functions f(n) and g(n) are called upper and lower bounds of the asymptotic complexity of the algorithm and the following is true by definition:

A

Ω(f(n)) ≤ Θ(f(n)) ≤ O(f(n)).

100
Q

blank, blank and blank are formal notational methods for stating the growth of resource needs (time and storage) of an algorithm.

A

Big-O, Omega, and Theta

101
Q

The function that counts the atomic operations of an algorithm falls under the blank.

A

big-O function

102
Q

The function that counts the atomic operations of an algorithm is above blank.

A

the Omega function

103
Q

The blank falls between the big-O and Omega functions.

A

Theta function

104
Q
A