1.3 Algorithms and Programs
1.3 Algorithms and Programs
Verification - Checks done by a human to ensure that data/code is correct.
Algorithm - A set of instructions that takes an input and turns it into an output of some kind.
Constant - A value which doesn't get changed, but is set to a variable, so that it is easy to use multiple times. Eg. Pi
Local Variable - When defined, local variables will be confined to just that subroutine, which means its value will be cleared when the subroutine ends.
Global Variable - Can be used throughout the program, its value isn't deleted until the program ends.
Variable - A value that can be stored in RAM temporarily and be called upon whenever needed.
Validation - Checks done by a computer for spelling or syntax errors.
Sequence - A set of instructions that are carried out once each.
Selection - Where the program makes a decision. Eg. If statement
Repetition - Where a statement is repeated more than once. Eg. While/For loop
Scope - Where in a program a variable can be accessed
Terminator - Shows the start/end of the chart
Decision - Describes statements such as IF and ELSE
Input - For collecting the user's input
Output - Will output something to the user
Process - Handles things like variable assignment
O(1) - Constant time
O(log n) - Logarithmic time
O(n) - Linear time
O(n²) - Polynomial time
O(2ⁿ) - Exponential time
Function - A subroutine that will return a value. In this, parameters are used to "copy" the data that they hold, into the subroutine.
Procedure - A subroutine that doesn't return a value
Parameters by value - Any variable that goes into the function/procedure is unchanged (although the new variable may be changed)
Parameters by reference - Where the variable outside the function/procedure is changed by it.
Linear Search - Compares each value in a list, one at a time until it finds the correct value.
Binary Search - Compares the middle item in a list, decides if it's too big or too small, then finds the middle of the correct half and repeats. Only works on sorted lists.
Insertion Sort - Takes each value one at a time, and puts it into the right order, until all values have been sorted
FOR i = 1 to 10 // OUTPUT i // NEXT i
MOD - Outputs the remainder of a division
Arrays - Names ← ["Adam", "Ryan", etc]
Code that's split into different sections, and could run by itself. Together it makes a bigger program. Eg. Login Screen/Different sections in a game.
Can be created by different programmers who specialise in that specific section.
Tested separately, and is easier to spot the bugs (because smaller program).
Lossless - Compression that doesn't change the file in any way, but makes use of repeating phrases and words. Eg. Run Length Encoding (RLE) would turn 0000 0110 into 5(0) ; 2(1) ; 0
Lossy - Compression that removes data that might be deemed unneeded. Eg. Lowering a picture's quality