COMPUTER SCIENCE Flashcards
Algorithm
A sequence of instructions to compete a task.
Computer program
An implementation of an algorithm.
Decomposition
Breaking a problem down into sub-problems.
Efficiency
Comparison of time 2 algorithms take.
Binary Search
More efficient. Ordered array. Takes index at highest and lowest. It is compared to the midpoint. If the value is the midpoint it returns True. Else it looks at the upper or lower section and repeats. If 2 boundary indexes are equal it returns False.
Linear search
Less efficient. Searches across an entire array until the value is located. It requires more steps than binary.
Bubble Sort
Less efficient. Compares 2 values, if they aren’t in order they’re swapped. It moves along the array. May pass over multiple time until there are no swaps.
For 200 elements = 40000 Comparisons
Merge Sort
Breaks array down into individual elements and builds them back up into a sorted array.
For 200 elements = 1600 comparisons
Data Type
Range of values a variable can hold.
Identifier
Variable name. Describes it’s purpose.
Definite iteration
Loops for a known number of times.
Indefinite
Number of loops is unknown.
Selection
Branches code using Boolean logic.
Single branch selection
IF
2-branch selection
IF-ElSE
Multiple branch iteration
ELSE-IF
Nested iteration
Iteration within another iteration or selection.
Integer Division
DIV
Modulus
MOD
Data Strucures
Hold multiple related values in one place.
Index starts at..
0
2 dimensional array.
Arrays as elements of an array.
Subroutine
Block of code,
‘out of line’ : only runs when called upon.
Parameters
The value a subroutine takes.