Back to the topic

The mark scheme starts on a new page, so you can print pages one and two for a student and keep the last page yourself. Everything prints in black on white whichever theme you are using.

Edexcel GCSE CS · 1.2

Algorithms, Flowcharts and Pseudocode

Section A: 10 multiple choice questions, 10 marks. Section B: 5 written questions, 17 marks. Total 27 marks.

Name

Class

Date

Mark  / 27

Section A

Circle the letter of the correct answer. One mark each.

  1. 1In the Edexcel pseudocode command set, how is a value assigned to a variable?1
    1. Atotal = 0
    2. BSET total TO 0
    3. Ctotal := 0
    4. DLET total BE 0
  2. 2Which flowchart symbol is used for a decision?1
    1. AA parallelogram
    2. BA rectangle
    3. CA rounded rectangle
    4. DA diamond
  3. 3What does RECEIVE age FROM (INTEGER) KEYBOARD do?1
    1. ASets age to the integer zero
    2. BReads a value typed by the user and treats it as a whole number
    3. CChecks whether age is an integer and reports an error
    4. DOutputs the value of age to the screen
  4. 4Which loop always executes its body at least once?1
    1. AREPEAT ... UNTIL
    2. BFOREACH ... END FOREACH
    3. CFOR ... END FOR
    4. DWHILE ... END WHILE
  5. 5A trace table is used to:1
    1. AStore test data for the final program
    2. BMeasure how much memory a program uses
    3. CRecord the value of each variable after every step so the algorithm can be checked by hand
    4. DConvert pseudocode into machine code
  6. 6What is output by this algorithm? SET x TO 5, WHILE x > 8 DO, SEND x TO DISPLAY, SET x TO x + 1, END WHILE1
    1. A5 6 7 8
    2. BNothing at all
    3. C5
    4. DIt loops forever
  7. 7In Edexcel pseudocode, what does the symbol & do in SEND 'Total: ' & total TO DISPLAY?1
    1. AAdds the two values as numbers
    2. BMarks the end of the statement
    3. CJoins the two values together into one string for output
    4. DCompares the two values
  8. 8Which element of a flowchart is drawn as a parallelogram?1
    1. AA process
    2. BA decision
    3. CInput or output
    4. DThe start of the algorithm
  9. 9A program must ask a user for a menu choice and keep asking until the choice is valid. Which construct fits best?1
    1. AREPEAT ... UNTIL
    2. BFOREACH
    3. CA FOR loop
    4. DA single IF statement
  10. 10Why is an algorithm not the same thing as a program?1
    1. AAn algorithm always contains a loop and a program does not
    2. BAn algorithm cannot contain selection
    3. CAlgorithms are written by computers and programs by people
    4. DAn algorithm is the logic, and a program is that logic written in a specific language a computer can run

Section B

Answer in the space provided. The number of marks tells you how many separate points to make.

  1. 1StateState two differences between a WHILE loop and a REPEAT UNTIL loop.2
  2. 2DescribeDescribe the purpose of a trace table and explain how it helps a programmer find a logic error.3
  3. 3DescribeDescribe three rules that must be followed when drawing a flowchart.3
  4. 4WriteWrite an algorithm, using pseudocode or a flowchart, that asks the user for ten numbers, adds them up and outputs the total.5
  5. 5ExplainExplain why an algorithm might be written as pseudocode before it is written as a program in Python.4

Mark scheme

Section A

1B2D3B4A5C6B7C8C9A10D

Section B

1 State two differences between a WHILE loop and a REPEAT UNTIL loop. 2

One mark for each of the following, to a maximum of 2.

  • A WHILE loop tests its condition before the body runs and a REPEAT loop tests it afterwards
  • A WHILE loop may run zero times, a REPEAT loop always runs at least once

Model answer. A WHILE loop tests its condition before the body is executed, whereas a REPEAT UNTIL loop executes the body first and tests the condition afterwards. As a result, the body of a WHILE loop may never run at all if the condition is false to begin with, while the body of a REPEAT UNTIL loop always runs at least once.

2 Describe the purpose of a trace table and explain how it helps a programmer find a logic error. 3

One mark for each of the following, to a maximum of 3.

  • It records the value of each variable at each step of the algorithm
  • The programmer can compare the actual values with the values expected
  • The step at which a value first becomes wrong identifies where the error is

Model answer. A trace table records the value held by every variable after each step of an algorithm, together with anything the algorithm outputs. Working through the algorithm by hand and filling the table in lets the programmer compare the values the program actually produces with the values it should be producing at that point. The first row where a value differs from what was expected shows exactly which instruction is at fault, which is what makes a trace table so effective at locating logic errors, since a logic error produces a wrong answer without producing any error message at all.

3 Describe three rules that must be followed when drawing a flowchart. 3

One mark for each of the following, to a maximum of 3.

  • A decision is shown as a diamond containing a condition with two labelled outputs
  • Input and output use a parallelogram and a process uses a rectangle
  • The flowchart begins and ends with a terminal symbol and every step is joined by arrows showing the flow

Model answer. A flowchart must begin and end with a terminal symbol, a rounded rectangle containing START or STOP, so that it is clear where the algorithm starts and finishes. Each type of step must use the correct shape: a rectangle for a process such as a calculation, a parallelogram for input or output, and a diamond for a decision. A decision must contain a condition rather than an instruction and must have exactly two outputs, each labelled Yes or No, and every symbol must be connected by arrows that show the direction the algorithm flows in, with any loop drawn as an arrow returning to a point earlier in the sequence.

4 Write an algorithm, using pseudocode or a flowchart, that asks the user for ten numbers, adds them up and outputs the total. 5

One mark for each of the following, to a maximum of 5.

  • A total is initialised to zero before the loop
  • A loop that repeats exactly ten times
  • A number is input from the user inside the loop
  • The number is added to the running total inside the loop
  • The total is output after the loop has finished

Model answer. SET total TO 0, then FOR count FROM 1 TO 10 DO, and inside that loop SEND 'Enter a number' TO DISPLAY, RECEIVE number FROM (INTEGER) KEYBOARD and SET total TO total + number, then END FOR, and finally SEND total TO DISPLAY. The total must be set to zero before the loop begins so that it is not reset on each pass, the input and the addition both sit inside the loop so that they happen ten times, and the output sits after END FOR so that the total is displayed once, when all ten numbers have been added.

5 Explain why an algorithm might be written as pseudocode before it is written as a program in Python. 4

One mark for each of the following, to a maximum of 4.

  • Pseudocode is not tied to any one programming language
  • The programmer can concentrate on the logic without worrying about syntax
  • It is easier for other people, including non programmers, to read and check
  • Errors in the design can be found and corrected before time is spent coding

Model answer. Pseudocode is deliberately not tied to any particular programming language, so the programmer can set out the logic of the solution without having to be correct about the syntax of Python at the same time. That separation matters because it means the design can be judged on whether the steps are right, rather than on whether a colon or a bracket is missing. Pseudocode is also far easier for other people to read, including team members who work in a different language and clients who do not program at all, so the design can be reviewed and agreed before any code exists. Finding a flaw in the logic at that stage costs a few minutes, whereas finding the same flaw after the program has been written, tested and documented costs a great deal more.