You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
This lesson covers algorithmic thinking, a core component of computational thinking as required by OCR J277 Section 2.1. Algorithmic thinking is about designing clear, logical, step-by-step solutions to problems.
An algorithm is a precise, step-by-step set of instructions for solving a problem or completing a task. An algorithm must be:
| Property | Description |
|---|---|
| Finite | It must have a definite end — it cannot run forever |
| Precise | Each step must be clearly defined and unambiguous |
| Effective | Each step must be achievable (it can actually be carried out) |
| Ordered | The steps must be in the correct sequence |
Algorithms are not just for computers — we use them in everyday life:
| Task | Algorithm |
|---|---|
| Making tea | 1. Boil water. 2. Put tea bag in cup. 3. Pour water into cup. 4. Wait 3 minutes. 5. Remove tea bag. 6. Add milk if desired. |
| Getting dressed | 1. Choose clothes. 2. Put on underwear. 3. Put on shirt. 4. Put on trousers. 5. Put on socks. 6. Put on shoes. |
| Crossing the road | 1. Stop at the kerb. 2. Look left. 3. Look right. 4. Look left again. 5. If road is clear, cross. 6. Otherwise, wait and repeat. |
OCR Exam Tip: An algorithm is NOT a program. An algorithm is the plan (language-independent). A program is the implementation of an algorithm in a specific programming language. You can express an algorithm in English, pseudocode, or a flowchart.
Algorithmic thinking is the ability to define clear, step-by-step instructions for solving a problem. It involves:
Algorithms can be represented in three main ways:
| Method | Description | When Used |
|---|---|---|
| Written description | Plain English steps | Initial planning, explaining to non-technical people |
| Pseudocode | Structured, code-like language that is not tied to any programming language | Detailed design, OCR exam questions |
| Flowcharts | Visual diagrams using standard symbols | Visual learners, design documentation, OCR exam questions |
We will cover pseudocode and flowcharts in detail in later lessons.
Sequence means executing instructions one after another in order.
Step 1: Input the first number
Step 2: Input the second number
Step 3: Add the two numbers together
Step 4: Output the result
Selection means choosing which instructions to execute based on a condition.
Step 1: Input the temperature
Step 2: IF temperature > 30 THEN
Step 3: Output "It is hot"
Step 4: ELSE
Step 5: Output "It is not hot"
Step 6: ENDIF
Iteration means repeating a set of instructions, either a fixed number of times or until a condition is met.
Count-controlled loop (FOR loop):
FOR i = 1 TO 10
Output i
NEXT i
Condition-controlled loop (WHILE loop):
WHILE answer != "quit"
Input answer
ENDWHILE
| Construct | Symbol | Purpose |
|---|---|---|
| Sequence | Instructions in order | Execute steps one after another |
| Selection | IF...THEN...ELSE | Make decisions based on conditions |
| Iteration | FOR / WHILE | Repeat instructions |
OCR Exam Tip: Sequence, selection, and iteration are the three fundamental programming constructs. Every algorithm is built from combinations of these three. Make sure you can identify which construct is being used in a given piece of pseudocode or flowchart.
Problem: Design an algorithm that asks the user for 5 numbers and outputs the largest.
Step-by-step design:
largest to a very small number (or the first input).largest, update largest.largest.In pseudocode:
largest = 0
FOR i = 1 TO 5
INPUT number
IF number > largest THEN
largest = number
ENDIF
NEXT i
OUTPUT largest
These patterns appear frequently in problems and exams:
| Pattern | Description |
|---|---|
| Linear search | Check each item in a list one by one until you find the target |
| Counting | Use a counter variable to count how many items meet a condition |
| Totalling | Use a running total to add up values |
| Finding max/min | Track the largest or smallest value seen so far |
| Validation | Check that input meets certain criteria before accepting it |
| Authentication | Compare entered credentials against stored values |
After designing an algorithm, you should test it with different inputs:
| Test Type | Description | Example |
|---|---|---|
| Normal data | Typical, expected inputs | Numbers within the expected range |
| Boundary data | Values at the edge of acceptable ranges | The minimum and maximum allowed values |
| Erroneous data | Invalid or unexpected inputs | Text when a number is expected, negative values |
OCR Exam Tip: When asked to design an algorithm, always consider what happens with unusual inputs. A good algorithm handles edge cases (e.g. what if the user enters a negative number, or the list is empty?). Mentioning this in your answer shows deeper understanding.
Algorithmic thinking is the ability to design clear, step-by-step solutions to problems. Every algorithm uses sequence, selection, and iteration. Algorithms can be represented as written descriptions, pseudocode, or flowcharts. For the OCR J277 exam, practise designing algorithms for common problems (searching, counting, finding max/min) and testing them with normal, boundary, and erroneous data.
Problem: Design an algorithm for a cash machine login. The user must enter a four-digit PIN. If the PIN matches the stored PIN the user is granted access. If the PIN is wrong, the user gets up to three attempts in total, after which the card is retained.
Step 1 — Understand the requirements. What are the inputs, outputs, and edge cases?
Step 2 — Identify the constructs needed.
Step 3 — Draft pseudocode.
storedPIN = "4271"
attempts = 0
accessGranted = False
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.