Send a link to your students to track their progress
40 Terms
1
New cards
components of algorithm
sequencing, selection, iteration
2
New cards
sequencing
the order in which things will be done, or step by step
3
New cards
selection
choosing which items to process, usually done via conditional statement
4
New cards
iteration
repeating the above until the task is done
5
New cards
algorithm- inputs&outputs
if an algorithm is presented with the same inputs (and the hardware isn;t broken) it will give exactly the same outptus
6
New cards
algorithm 3 classes
decidable, undecidable, uncomputable
7
New cards
desirable algorithm
increases linearly with the size of the data set (doubling the data doubles the processing time)
8
New cards
when is an algorithm "reasonable"
if it runs into no worse than polynomial time
9
New cards
when is an algorithm "unreasonable"
since they are processed for small collections of data, after the first few data item the times become huge (PROCESSING TIME INCREASES)
10
New cards
decidable problem
one in which an algorithm can be constructed to answer "yes" or "no" for all inputs
11
New cards
undecidable problem
one where no algorithm can be created that gives a correct "yes or no" answer- have no algorithmic solution- no algorithm that solves all instances of the problem
12
New cards
repetition (iteration, loops) statements
allow us to execute a statement multiple times
13
New cards
REPEAT-TIMES
loops is best suited for executing a specific number of repetitions that can be determined in advance
14
New cards
REPEAT n TIMES
15
New cards
{
16
New cards
17
New cards
}
18
New cards
REPEAT-UNTIL
REPEAT UNTIL (condition)
19
New cards
{
20
New cards
21
New cards
}
22
New cards
body of REPEAT-UNTIL loop eventually...
makes the test condition true- if not, infinite loop
23
New cards
infinite loop
executes until the user interrupts the program
24
New cards
nested loops
the body of a loop can contain another loop, each time through the outer loop, the inner loop goes through its full set of iterations
25
New cards
unbounded iteration
when you cannot determine how many times you want to execute the look body, use REPEAT-UNTIL statement
26
New cards
bounded iteration
when you can determine how many times you want to execute the loop body, use a REPEAT-TIMES statement
27
New cards
list
ordered sequence of vales
28
New cards
list elements
values in lists
29
New cards
number of items in a list can be determined by using the LENGTH () function:
LENGTH (scores)
30
New cards
linear/sequential search
examines each item of the list in turn until the desired item is found
31
New cards
FOR-EACH loop
used to access each item in a list in turn
32
New cards
common index variable
i
33
New cards
general format for processing all items in list
i - 1
34
New cards
REPEAT LENGTH (scores) TIMES
35
New cards
{
36
New cards
item specific code
37
New cards
i - i + 1
38
New cards
}
39
New cards
no score value should exceed
100
40
New cards
binary search
more efficient than linear search but can be only performed on a list where the items are already in order, examines the middle item and moves left if the desired item is less than the middle, and right if the desired item is great- process repeats until item is found