Pearson Edexcel 1CP2 GCSE Computer Science · Topic 1: Computational Thinking

Stretch tasks Algorithms, Flowcharts and Pseudocode

Task 1

Quiz Challenge

A quiz game against four computer players, then short and long written answers.

  1. Quiz Blitz12 questions against the clock
  2. Quick Fire4 short answers
  3. Big Think2 long answers

About 20 minutes

Task 2

This or That

Pixel the cat asks 8 questions. Each has two answers: pick the right one.

  • Two answers to every question
  • A fish treat for every right answer
  • Streaks win Pixel shades, then a party hat

About 4 minutes

Task 3

Memory Match

Flip the cards two at a time to match each term card to its meaning card.

  • 12 cards: each term has a meaning
  • One peek at every card
  • Combo points for pairs found in a row

6 pairs, about 4 minutes

Task 4

Sort It

Sort each statement into the right box, like the tick-box tables in the exam.

  • 12 cards to sort into 4 boxes
  • Drag a card, tap a box or press its number
  • Combo points for cards sorted in a row

12 cards, about 4 minutes

The games need JavaScript. Every question is below, with the answers at the end.

Read the lesson: Algorithms, Flowcharts and Pseudocode

Algorithms, Flowcharts and Pseudocode: the questions

Quiz Challenge, round 1: Quiz Blitz

  1. Which flowchart symbol holds a decision?

    • A rounded rectangle
    • A rectangle
    • A diamond
    • A parallelogram
  2. Which flowchart symbol is used for input and output?

    • A circle
    • A parallelogram
    • A diamond
    • A rectangle
  3. What is sent to the display?

    SET total TO 0
    SET count TO 1
    WHILE count <= 4 DO
        SET total TO total + count
        SET count TO count + 1
    END WHILE
    SEND total TO DISPLAY

  4. How does Edexcel pseudocode assign 5 to x?

    • LET x BE 5
    • SET x TO 5
    • x = 5
    • x <- 5
  5. A REPEAT ... UNTIL loop always runs at least once.

    • True
    • False
  6. A WHILE loop always runs at least once.

    • True
    • False
  7. What does this send to the display?

    SET name TO 'Priya'
    SEND 'Hello ' & name TO DISPLAY
    • Hello Priya
    • Hello & name
    • 'Hello ' & Priya
    • name
  8. What does a function do that a procedure does not?

    • Runs code
    • Returns a value
    • Takes parameters
    • Has a name
  9. In Edexcel pseudocode, what does <> mean?

    • Not equal to
    • Less than
    • Joins two strings
    • Assignment
  10. Which TWO belong in a trace table?

    Tick 2.

    • The program's file name
    • A flowchart
    • A column for each variable
    • A new row every time a value changes
    • Only the final answer
  11. What is sent to the display?

    SET scores TO [12, 7, 19, 3]
    SEND scores[1] TO DISPLAY

  12. Why must a total be initialised before a loop, not inside it?

    • Loops cannot contain SET
    • It runs faster
    • Edexcel forbids it
    • Inside, it would reset on every pass

Quiz Challenge, round 2: Quick Fire

  1. Explain the difference between an algorithm and a program. [2 marks]

  2. Explain the difference between a WHILE loop and a REPEAT ... UNTIL loop. [2 marks]

  3. This algorithm should keep asking until the password is correct, but it loops forever after one wrong guess. Explain why, and how to fix it. [2 marks]

    RECEIVE password FROM (STRING) KEYBOARD
    WHILE password <> 'letmein' DO
        SEND 'Wrong' TO DISPLAY
    END WHILE
    SEND 'Access granted' TO DISPLAY

  4. Describe how to complete a trace table so that it earns marks even if you make a slip. [2 marks]

Quiz Challenge, round 3: Big Think

  1. Write an algorithm, in pseudocode, that asks the user for 10 numbers and then displays their total and how many of them were negative. [6 marks]

  2. A student's flowchart for a password check has a decision diamond containing 'add one to attempts', an unlabelled branch, and a loop arrow that rejoins below the input. Explain each error and how to correct it. [6 marks]

This or That: tick the right answer

  1. Which shape is used for START and STOP?

    • A diamond
    • A rounded rectangle
  2. Which loop can run zero times?

    • WHILE
    • REPEAT ... UNTIL
  3. Which loop walks through every element without handling an index?

    • WHILE
    • FOREACH
  4. Edexcel or OCR: SEND total TO DISPLAY?

    • Edexcel
    • OCR
  5. Which returns a value with RETURN?

    • A procedure
    • A function
  6. Where must a loop arrow rejoin, so the user is asked again?

    • Above the input
    • Below the input
  7. scores is [12, 7, 19, 3]. What is scores[3]?

    • 3
    • 19
  8. In a trace table, overwrite old values or add a new row?

    • Add a new row
    • Overwrite them

Memory Match: match each term to its meaning

TermMeaning
A Algorithm1 A subprogram that returns a value
B Trace table2 Precise steps that always finish
C Decision symbol3 Rounded rectangle for START and STOP
D Terminal symbol4 Records each variable after every step
E Function5 A subprogram that returns nothing
F Procedure6 A diamond holding a condition

Sort It: tick one box in each row

Which flowchart symbol would each step use?

StatementTerminalProcessInput or outputDecision
STOP
START
Read the password
Enter the user's age
Display 'Access granted'
Set count to 0
Print the total
Add one to attempts
age >= 18?
total = total + price
Is the password correct?
count > 10?
Answers

Round 1: Quiz Blitz

  1. A diamond A diamond holds a condition with two labelled outputs.
  2. A parallelogram Reading data in and sending data out both use a parallelogram.
  3. 10 1 + 2 + 3 + 4 = 10.
  4. SET x TO 5 Assignment is SET ... TO.
  5. True It tests its condition after the body.
  6. False It tests first, so it can run zero times.
  7. Hello Priya & joins values together.
  8. Returns a value A function uses RETURN. A procedure does a job and returns nothing.
  9. Not equal to = compares for equality and <> for not equal.
  10. A column for each variable; A new row every time a value changes The history of values is the working, and the working earns marks.
  11. 7 Indices start at 0, so scores[1] is the second element.
  12. Inside, it would reset on every pass A total set to 0 inside the loop loses everything added so far.

Round 2: Quick Fire

    • An algorithm is a sequence of steps, in any form
    • A program is an algorithm written in a programming language so a computer can run it
    Model answer

    An algorithm is a precise sequence of steps that solves a problem, which can be written as a flowchart or pseudocode. A program is an algorithm written in a particular programming language, such as Python, so that a computer can run it.

    • WHILE tests its condition before the body, so it may run zero times
    • REPEAT ... UNTIL tests after the body, so it always runs at least once
    Model answer

    A WHILE loop tests its condition before the body, so it can run zero times. A REPEAT ... UNTIL loop tests its condition after the body, so it always runs at least once.

    • The password is only read once, so the condition never changes
    • Add a RECEIVE inside the loop
    Model answer

    The password is only read once, before the loop, so inside the loop it never changes and the condition stays true forever. A RECEIVE password FROM (STRING) KEYBOARD line must be added inside the loop, so the user is asked again on every pass.

    • One column for each variable, and for output
    • A new row every time a value changes, never overwriting
    • Work one line at a time, using the current values
    Model answer

    Draw one column for each variable and one for output, and write the starting values in the first row. Work through the algorithm one line at a time, adding a new row every time a value changes rather than overwriting it, so the working shows even if one value is wrong.

Round 3: Big Think

    • A loop that runs 10 times
    • RECEIVE a number inside the loop
    • Set the total to 0 before the loop
    • Add each number to the total
    • Test whether the number is below 0
    • Add 1 to a count of negatives
    • Send the total to the display after the loop
    • Send the count of negatives to the display
    Model answer
    PSEUDOCODE
    SET total TO 0
    SET negatives TO 0
    FOR index FROM 1 TO 10 DO
        RECEIVE number FROM (INTEGER) KEYBOARD
        SET total TO total + number
        IF number < 0 THEN
            SET negatives TO negatives + 1
        END IF
    END FOR
    SEND total TO DISPLAY
    SEND negatives TO DISPLAY
    • A diamond must hold a condition, not a statement
    • Such as attempts < 3
    • The statement belongs in a process rectangle
    • Both branches must be labelled Yes and No
    • Otherwise nobody can tell which way the algorithm goes
    • The loop arrow must rejoin above the input
    • Otherwise the same wrong password is tested forever
    • So the user is asked again each time
    Model answer

    A decision diamond must contain a condition with two possible answers, such as attempts < 3, not a statement. The statement 'add one to attempts' belongs in a process rectangle. Both branches out of the diamond must be labelled Yes and No, otherwise nobody can tell which way the algorithm goes. The loop arrow must rejoin above the input, so the user is asked again each time. Rejoining below the input means the same wrong password is tested forever.

This or That

  1. A rounded rectangle The terminal symbol is a rounded rectangle, one at each end.
  2. WHILE WHILE tests first. REPEAT tests after the body, so it always runs once.
  3. FOREACH FOREACH visits each element of a data structure in turn.
  4. Edexcel OCR writes print(total). Edexcel writes SEND ... TO DISPLAY.
  5. A function A procedure does a job but returns nothing.
  6. Above the input Rejoining below the input tests the same value forever.
  7. 3 Indices start at 0, so scores[3] is the fourth element.
  8. Add a new row The history is the working, and the working earns the marks.

Memory Match

  • A 2 Algorithm: Precise steps that always finish
  • B 4 Trace table: Records each variable after every step
  • C 6 Decision symbol: A diamond holding a condition
  • D 3 Terminal symbol: Rounded rectangle for START and STOP
  • E 1 Function: A subprogram that returns a value
  • F 5 Procedure: A subprogram that returns nothing

Sort It

  1. Terminal STOP STOP sits in a rounded rectangle too.
  2. Terminal START START sits in a rounded rectangle.
  3. Input or output Read the password Reading data in uses a parallelogram.
  4. Input or output Enter the user's age Input uses a parallelogram.
  5. Input or output Display 'Access granted' Sending data out uses a parallelogram.
  6. Process Set count to 0 An assignment is a process.
  7. Input or output Print the total Output uses a parallelogram.
  8. Process Add one to attempts A statement belongs in a process box, never a diamond.
  9. Decision age >= 18? A comparison is a decision.
  10. Process total = total + price A calculation is a process rectangle.
  11. Decision Is the password correct? A yes or no question is a decision.
  12. Decision count > 10? A condition with two answers goes in a diamond.