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.
Local variable
Only accessible in a subroutine.
Structured programming.
Using subroutines as part of decomposition.
Data validation routine
Ensure the user has entered a valid format or in correct range.
Test Data
The given values and compared with expected.
Normal Data
Everyday data,
Should be accepted, Not at boundary.
Boundary Data
At limits of what should and shouldn’t be accepted.
Erroneous Data
Should not be accepted, may also be boundary
Machine Code
Processors need code in this form to execute.
Assembly language.
Binary instructions given short words to represent. 1:1 relationship.
Assembler
Converts assembly language to machine code.
Processor families
Have their own specific assembly and machine code.
High-level language
Most commonly written in. Must be converted to low-level machine code. More expressive - shorter. Easily understood
Why write in low-level.
If a compiler does not exist for the hardware or you need high level control.
Compiler
On developers computer. Takes source code and converts to machine code for a specific processor family. Optimised and efficient. Hides original source code.
Interpreter.
Exists on the receiving computer. Converts line by line. Less optimised. Source code is visible. However more portable.
Hexadecimal
Uses placeholder of 16 and least significant of 1.
Bit
1 or 0
Byte
8 bits
Left shift
Multiply by 2.
Right shift.
DIV 2
Fixed-length character encodings
Universal way of encoding text. ASCII or UNICODE.
ASCII number of bits
7 bits
‘A’ in ASCII
65
Bitmap
Grid of pixels
Pixel
Smallest individual point of colour.
Resolution
Number of pixels used (width * height)
Colour Depth
Bits to encode a pixel
Analogue
Continuous data.
How analogue is converted to electrical signal.
Using a microphone.
Sample Rate
Number of samples per second. Measured in Hz.
Sample resolution
Bits to encode each level.
Compression
Making information take up less space.
Lossless compression.
None of original data is lost. RLE or Huffman coding.
RLE ideal situation
Repeating values
Where RLE may save space
Random data
Huffman coding guarantee
To never use more space than original.
Hardware
Physical components.