1/31
Looks like no tags are added yet.
Algorithm
A precise method for solving a problem
Decomposition
Breaking down a problem into smaller, more manageable sub programs which then make it easier to solve.
Benefits of decomposition
1. Reduces complexity
2. Different sub programs can be worked on simultaneously
3. Each sub program can be isolated and tested individually
4. Sub programs often lead to the creation of independent, reusable codes
Examples of decomposition irl
Video game design:
Decomposed into individual layers (character mechanics, world landscape design, sound engineering etc)
Abstraction
The process of removing or hiding unnecessary information so only the important details remain.
Benefits of abstraction
1. Reduces complexity
2. Prevents information overload
3. Saves time and resources
Examples of abstraction irl
London Underground map:
Only shows what a commuter needs, and omits unnecessary details
Flow chart
A graphical representation of an algorithm
Flow Chart Symbols
DIV (//)
Quotient ( only returns whole number)
MOD (%)
Modulo/Modulus ( Only returns remainder)
**/^
exponentiation ( To the power of)
Variable
A named location in computer memory that stores a value that can change
Constant
A named location in computer memory that stores a value that cannot change
Syntax error
An error that breaks the grammatical rules of a programming language and stops it from running
Examples
1. Typos and spelling errors
2. Incorrect use of operators
3. Invalid variable or function names
Logic error
Incorrect correct code is used. Program still runs but produces incorrect output as a result
Examples
1. Infinite loops
2. Incorrect use of operators
3. Using variables before they are assigned
Runtime error
An error that causes the program to crash
Examples
1. Dividing a number by 0
2. Index out of range of an array
3. Unable to read or write a drive
Relational Operators
1. Equal to
2. Not equal to
3. Less than
4. Less than I'd equal to
5. Greater than
6. Greater than or equal to
Equal to
==
Not equal to
!=
Less than
<
Less than or equal to
Greater than
>
Greater than or equal to
>=
Logical operators
1. And
2. Or
3. Not
( logical operators are always used alongside relational operators to form a comparison)
Not Gate
Input is always opposite to output
Eg: Input (A)
Output (Not A)
And Gate
Both Inputs have to be on in order for output to be in
Eg: Input (1,1) Input (0,1)
Output (1) Output (0)
Or gate
Only one input must be on for output to be on
Eg: Input (0,0) Input (0,1)
Output (0) Output (1)
Truth Table Structure
Input columns/Output columns