whole paper 2 cs

Cards (76)

  • Algorithm
    A sequence of steps that can be followed to complete a task
  • Algorithmic thinking

    Solving problems by defining steps and the sequence needed
  • Program code is just implementing an algorithm
  • Algorithms
    • Can be represented in pseudocode
    • Can be represented in flowcharts
  • Pseudocode
    Resembling code but more relaxed
  • Flowchart
    • Has a set group of symbols including start/end, process, sub-program, input/output
    • Uses a diamond for selection decisions
  • Abstraction
    Removing unnecessary detail from a problem
  • Decomposition
    Breaking down a problem into sub-problems
  • Structure diagram
    Represents decomposition of a larger problem into sub-problems
  • Trace table

    Shows how values change when an algorithm is carried out
  • Trace tables

    • Go through every line of code
    • Only add to a column when that value changes
    • Generally move to a new row when moving to a new block of code
  • Linear search

    Looks for a target by comparing each item in a list one by one
  • Binary search

    Compares the middle item to the target, discards half the list, and repeats until the target is found or the list is exhausted
  • Searching algorithms

    • Linear search doesn't require the list to be ordered
    • Binary search requires the list to be ordered
  • Bubble sort

    Does a series of passes, swapping pairs if needed, until a full pass happens with no swaps
  • Merge sort
    1. Divide the list continuously by two until each list has one item
    2. Merge the lists back together keeping them in order
  • Insertion sort
    Starts with one item in a sorted part, moves items one by one from the unsorted part to the sorted part
  • In section A of the exam, you can answer algorithm questions in your own way
  • In section B of the exam, you may need to answer in a programming language, either a real one or the OCR exam reference language
  • Data types

    • Integer
    • Real (float)
    • Boolean
    • String
    • Character
  • Casting
    Converting between data types
  • Arithmetic operations

    • Addition
    • Subtraction
    • Multiplication
    • Division (real and integer)
    • Exponentiation
  • Modulus
    Gives the remainder of a division
  • Comparison operators

    • Equal to
    • Not equal to
    • Greater than
    • Greater than or equal to
    • Less than
    • Less than or equal to
  • Boolean
    Logical operations of AND and OR
  • Substring
    Extracts part of a string
  • Concatenation
    Joining two strings together
  • Variable
    An identifier that holds a value that can be changed
  • Constant
    An identifier that holds a value that cannot be changed
  • Getting user input

    1. Assign the user input to a variable
    2. May need to cast the input to a different data type
  • Random function
    Generates a random number
  • Programming constructs

    • Sequence (lines executed in order)
    • Selection (if/elif/else statements, switch statements)
    • Iteration (for loops, while loops, do-until loops)
  • While loop

    1. Repeat until a condition is broken
    2. Useful when you don't know how many times the loop needs to repeat
  • Do until loop (do while loop)
    1. Repeat until a condition is met
    2. Runs at least once even if condition is false
  • Subprogram (subroutine)

    Named out-of-line block of code
  • Procedure
    Type of subprogram
  • Function
    Type of subprogram that has a return value
  • Parameter
    Variable used as an input to a subprogram
  • Return value
    Output from a subprogram
  • Local variable
    Variable that only exists when the subprogram is executing and is only accessible inside the subprogram