1/24
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
Definition of Decomposition
The process of breaking a problem down into smaller parts.
Benefits of decomposition
It is often easier to solve several small problems than one big problem.
Different modules(parts) of the program can be worked on by different developers simultaneously, which speeds up the development process
Different modules can be tested independently, ensuring that they work before they come together to form the whole solution. This means that when they are joined, there are fewer errors.
Abstraction
Removing unnecessary details and focusing on the important ones in order to make the problem simpler.
Examples of Abstraction
Subprograms: by giving a block of a code a name it abstracts the complexity of it. The user does not have to understand how it works and just has to call it.
Operating systems
Count-controlled loop
A loop that runs for a definite amount of time
Count-controlled loop
A loop that runs while a condition is true
Variable
A named location in memory that stores a value that can be changed as the program runs
Constant
A named location in memory that cannot be changed as the program runs
Integer
Any whole number, positive or negative
Float/Real
Any number with a fractional or decimal part
String
A collection of alphanumeric characters. In code strings are identified by quotation marks.
Character
A single alphanumeric character or symbol
Boolean
a True or False value
Casting
The process of converting from one data type to another
Array
A data structure that stores multiple elements of the same data type under the same identifier
Record
A data structure that stores multiple elements of different data types under the same identifier
Arithmetic operators
Addition : +
Substraction: -
Multiplication: *
Division : /
Integer division(DIV): //
Modulus(MOD, returns the remainder): %
Relational operators
=, !=, >, <, >=, <=
Logical operators
AND (returns true when both conditions are true)
OR (returns true when either of the conditions is true)
NOT (Reverses the outcome of the expression)
Trace tables
used to determine what value a variable will hold at a given point in an algorithm
go to the next line when a variable changes value
Syntax error
An error that breaks the grammatical rules of the programming language and stops the program from running, such as a typo, spelling mistakes, missing bracket or quotation marks,..
Runtime error
An error that causes the program to crash as the operation that the computer is asked to do is impossible, such as dividing by 0 or an index that’s out of range
Logical error
An error where incorrect code is used, causing the program to produce incorrect output. The program will still run.
Example : incorrect use of index, wrong relational operator, …etc.
Linear search
Linear search is the simplest way to find an item in a list.
You start at the first item and check each item one by one until:
you find the target → return its position, or
you reach the end of the list → the item is not there.
It works on any list — it does not need to be sorted.
Binary search
Binary search is a fast way to find an item in a sorted list.
It works by repeatedly cutting the list in half:
Look at the middle item.
If it is the target → found.
If the target is smaller, search the left half.
If the target is bigger, search the right half.
Repeat until found — or until nothing is left.
Because it halves the list each time, it is much faster than linear search.