OCR A Level Computer Science – Paper 2 Detailed Revision Notes
Topic 2.1: Algorithms
Definition:An algorithm is a step-by-step procedure or set of rules to solve a
problem or perform a task.
Key Concepts:
• Pseudocode:A simplified, human-readable way to describe algorithms,
using structured language that resembles programming code but without syntax
constraints.
• Flowcharts:Diagrams that represent algorithms using standardized
symbols (e.g., rectangles for processes, diamonds for decisions).
• Basic Algorithm Operations:
• Sequence: Instructions run in order.
• Selection: Decisions made using IF…THEN…ELSE or CASE statements.
• Iteration: Repeating instructions using loops (WHILE, FOR).
• Searching Algorithms:
• Linear Search: Checks each item sequentially until the target is found
or the list ends.
• Binary Search: Efficient search on sorted lists by repeatedly dividing
the search interval in half.
• Sorting Algorithms:
• Bubble Sort: Repeatedly swaps adjacent elements if they are in the
wrong order.
• Merge Sort: Divides the list into halves, sorts each half recursively,
then merges them.
• Insertion Sort: Builds a sorted list by inserting each new element into
its proper position.
Algorithm Efficiency:
• Measured by time complexity (how execution time increases with input
size) and space complexity (memory usage).
• Common notation: Big O notation, e.g.,
• Linear search: O(n)
• Binary search: O(log n)
• Bubble sort: O(n²)
• Merge sort: O(n log n)
Topic 2.2: Programming Techniques
• Variables and Constants: Containers for data values; constants hold
fixed values.
• Data Types: Integers, real numbers, characters, strings, Boolean.
• Operators: Arithmetic (+, -, *, /), comparison (==, !=, <, >), logical
(AND, OR, NOT).
• Input and Output: Receiving data from users and displaying results.
• Control Structures:
• Sequence, selection, iteration.
• Nested control structures.
• Procedures and Functions: Blocks of code designed to perform specific
tasks; functions return values, procedures do not.
• Parameters: Values passed into functions/procedures to make them
reusable and flexible.
• Recursion: Functions that call themselves with a base case to
terminate, useful for problems like factorial, Fibonacci sequences.
Topic 2.3: Producing Robust Programs
Robust Programs can handle errors gracefully and continue operating correctly.
• Defensive Design Techniques:
• Input validation to ensure data meets criteria.
• Handling unexpected user behavior.
• Testing Methods:
Topic 2.1: Algorithms
Definition:An algorithm is a step-by-step procedure or set of rules to solve a
problem or perform a task.
Key Concepts:
• Pseudocode:A simplified, human-readable way to describe algorithms,
using structured language that resembles programming code but without syntax
constraints.
• Flowcharts:Diagrams that represent algorithms using standardized
symbols (e.g., rectangles for processes, diamonds for decisions).
• Basic Algorithm Operations:
• Sequence: Instructions run in order.
• Selection: Decisions made using IF…THEN…ELSE or CASE statements.
• Iteration: Repeating instructions using loops (WHILE, FOR).
• Searching Algorithms:
• Linear Search: Checks each item sequentially until the target is found
or the list ends.
• Binary Search: Efficient search on sorted lists by repeatedly dividing
the search interval in half.
• Sorting Algorithms:
• Bubble Sort: Repeatedly swaps adjacent elements if they are in the
wrong order.
• Merge Sort: Divides the list into halves, sorts each half recursively,
then merges them.
• Insertion Sort: Builds a sorted list by inserting each new element into
its proper position.
Algorithm Efficiency:
• Measured by time complexity (how execution time increases with input
size) and space complexity (memory usage).
• Common notation: Big O notation, e.g.,
• Linear search: O(n)
• Binary search: O(log n)
• Bubble sort: O(n²)
• Merge sort: O(n log n)
Topic 2.2: Programming Techniques
• Variables and Constants: Containers for data values; constants hold
fixed values.
• Data Types: Integers, real numbers, characters, strings, Boolean.
• Operators: Arithmetic (+, -, *, /), comparison (==, !=, <, >), logical
(AND, OR, NOT).
• Input and Output: Receiving data from users and displaying results.
• Control Structures:
• Sequence, selection, iteration.
• Nested control structures.
• Procedures and Functions: Blocks of code designed to perform specific
tasks; functions return values, procedures do not.
• Parameters: Values passed into functions/procedures to make them
reusable and flexible.
• Recursion: Functions that call themselves with a base case to
terminate, useful for problems like factorial, Fibonacci sequences.
Topic 2.3: Producing Robust Programs
Robust Programs can handle errors gracefully and continue operating correctly.
• Defensive Design Techniques:
• Input validation to ensure data meets criteria.
• Handling unexpected user behavior.
• Testing Methods: