Repeat until the whole list is passed without any swaps
Merge sort
Split the list into many lists with only one element each
Pair up these lists, sorting elements within the newly formed list
Insertion sort
Start with the 2nd value
compare it to the value to the left
If the value on the left it bigger, swap them
continue this until the value on the left is smaller
repeat, looking for the next value which is smaller than the value to the left of it
Linear search
check each valueindividually against the target value
Binary search
check the middle value of the list against the target value
If the target value is larger than the middle value, disregard the middle value and lower, creating a new list
Same for if the target value is smaller
Repeat the process with the new list
Repeat until either the target value is found or only one value remains and it does notequal the target value, therefore the target value must not be in the list
File handling - pseudocode syntax
eg - opening the file "scores.txt" and adding "cheese"
.
file = openWrite("scores.txt")
file.writeLine("cheese")
file.close
File handling - python syntax
eg. opening the file "scores.txt" and adding "cheese"
.
file = open("scores.txt", "w")
file.write("cheese")
file.close()
.
.
GENERAL SYNTAX:
.
file = open([filename] , [mode])
file.write([write text])
data = file.read([line number or blank for whole file])
file.close()
.
.
MODES:
w - write (overwrites)
r - read
a - append (doesn't overwrite)
Syntax
Comment:
OCR: //
Python: #
Decimal:
OCR: real
Python: float
For loop:
OCR: for ...to ... - eg. [for i=0 to 9] ... [nexti]
Python: for ... inrange(9) - eg. [for i in range(9):] (print 0 to 8)
Syntax
string length:
OCR: string.length
Python: len(string)
substring:
OCR: string.substring([startingletter], [number of lettersforward])
Python: string[[starting letter]:[ending letter - 1]]
Uppercase:
OCR: string.upper
Python: string.upper
A programme written in a high level language is called source code
Low level languages
Machine code:
very powerful
very difficult to use (hex and binary)
Assembly language:
middle ground
uses mnemonics which correspond to a machine code instruction
Assembly language mnemonics
LDA - loads a value from memoryaddress
STA - stores a value in a memoryaddress
ADD - adds the value held in memoryaddress to value in the accumulator
SUB - subtracts the value in the memoryaddress from the value in the accumulator
MOV - moves the content from one memoryaddress to another
Machine code & assembly instructions
opcode - the actualinstruction
operand - the value the instructionuses or manipulates
Compiler - all at once, saved as an executable
Interpreter - line by line
Features of IDE:
editors - adding to and amending code
run-time environment - it can run the codeitself
automatic linenumbering
error trapping - pinpoint exactly where an error is
colour coding
breakpoints - programme can be paused at a specificlocation to test different aspects of the programme