COMP 2 Flashcards
Algorithm?
sequence of steps that can be followed to complete a task
Algorithms are represented by
pseudo-codes and flowcharts
Flowcharts
I/O
Start/End
Sub-Programme
Choice
Process
Algorithms are a________
Abstract - meaning it removed unnecessary details from the problem
Decomposition?
breaking a problem into smaller sub-problems which each represent a different task
Trace tables ?
shows how values change when an algorithm is carried out
bubble sort
goes through pairs in one pass and swaps if needs to . repeats until single pass happens with no swaps
merge sort
divided list continuously by 2 until each list has one item . then it combines two lists at a time in order
interger, real, boolean
interger - a whole number
float - decimal
boolean - true or false
character
string?
character - a letter , number or symbol
string - a group of characters
multiplication
exponentation (power of)
division
quotient (integer division)
modulus (remainder of quotient)
multiplication - *
exponentation - ^
division - /
quotient - DIV
modulus - MOD
bolean : NOT , AND , OR
NOT - opposite
AND - both sides needed
OR - only one side needed
e.g
if age < 40 AND name != “AJ”
if age < 40 OR name != “AJ”
string handling
SubString - .substring(start . howMany)
Concatenation - +
variables and constants
variables are identifiers that hold a value that can be changed
constant are identifiers that hold a value that cannot be changed
3 fundamental programming constructs
sequence
selection
iteration