Paper 2

Cards (15)

  • Bubble sort

    • Start at the beginning of the list
    • Compare with adjacent value
    • If in the wrong order then swap
    • Repeat with values 2 and 3
    • Continue until entire list is checked
    • 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 value individually 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 not equal 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] ... [next i]
    • Python: for ... in range(9) - eg. [for i in range(9):] (print 0 to 8)
  • Syntax
    string length:
    • OCR: string.length
    • Python: len(string)
    substring:
    • OCR: string.substring([starting letter], [number of letters forward])
    • 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 memory address
    • STA - stores a value in a memory address
    • ADD - adds the value held in memory address to value in the accumulator
    • SUB - subtracts the value in the memory address from the value in the accumulator
    • MOV - moves the content from one memory address to another
  • Machine code & assembly instructions
    • opcode - the actual instruction
    • operand - the value the instruction uses 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 code itself
    • automatic line numbering
    • error trapping - pinpoint exactly where an error is
    • colour coding
    • breakpoints - programme can be paused at a specific location to test different aspects of the programme
    • variable tracing
    • auto-correct
    • auto-suggestion
    • auto-indent
    • interpreters