Unit 1 Flashcards
To determine the best algorithms to use, computer scientists analyze the complexity of the algorithm by comparing two algorithms at the blank level
idea
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.
big-O, Theta, and Omega
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.
algorithm
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.
pseudocode
An important type of step in an algorithm is an blank, in which a variable is given a value.
assignment
An assignment operator is denoted by:
blank
x := y
The output of an algorithm is specified by a blank statement.
return
A description of an algorithm starts with the blank.
name of the algorithm
The name is followed by a blank of what the algorithm computes
description
A description of an algorithm usually includes what five steps:
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
An blank tests a condition, and executes one or more instructions if the condition evaluates to true.
if-statement
In a blank, a condition and instruction appear on the same line.
single line if-statement
What is the notation for an if-statement?
If (x = 5), y := 7
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
sequence
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
if-else-statement
Name the pattern for if-else statement
If ( condition )
One or more steps
Else
One or more steps
End-if
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.
condition
The structure of the if-then statement in pseudocode when there is only one step to execute when the condition is true is:
blank
If(condition), step
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:
End-if
The if-else statement in pseudocode is formatted in what format:
If (condition)
One or more steps
Else
One or more steps
End-if
The multiple step if statement in pseudocode is formatted in what format:
If (condition)
Step 1
Step 2
…
Step n
End-if
When needed, if-then and if-else statements can be blank
nested.
There are blank regarding how many if-then or if-else statements can be placed under another if-then or if-else statement.
no limitations
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.
iteration
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.
for-loops
Blank structures provide a means of specifying a sequence of steps that are to be repeated.
Looping
There are two common types of loops: blank and blank.
for-loops and while-loops
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.
for-loop
Each repetition of the block of instructions inside the for-loop is called an blank
iteration.
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.
starting value
Give the syntax for a for loop
For i = s to t
Step 1
Step 2
. . .
Step n
End-for
For-loops are used when the number of iterations in the loop is blank.
known
The for-loop iterates blank times.
final_value-start_value+1
A blank iterates an unknown number of times, ending when a certain condition becomes false.
while-loop
A while-loop is written as blank:
While ( condition )
Step 1
Step 2
. . .
Step n
End-while
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.
condition
blank are used when the number of iterations in the loop is unknown and may execute zero or more iterations.
While-loops
While loops are controlled by a blank. If the blank is true, the loop initiates an iteration otherwise it stops.
conditional statement
While-loops use the blank syntax in pseudocode:
While (condition)
One or more steps
End-while
The while-loop iterates blank or blank times until the condition is met.
zero or more
When a loop exists within another loop, it is called a blank loop
nested
When loops are nested the blank loop takes control of the number of complete repetitions of the blank loop.
outer
inner