Full Marks

GCSE Computer Science · Topic 6

Algorithms: representation, searching and sorting

Algorithms, representation, searching and sorting is about writing clear algorithms and choosing efficient ones.

We will write pseudocode and flowcharts, and use trace tables to find errors.

Then we compare linear and binary search, bubble, insertion and merge sort, and measure efficiency.

In this topic

  1. 6.1Writing algorithms in pseudocode and flowcharts (exam reference languages)Free below · 20 questions
  2. 6.2Trace tables, dry-running and finding errors in algorithmsOpen in Full Marks · 26 questions
  3. 6.3Searching algorithms: linear and binary searchOpen in Full Marks · 62 questions
  4. 6.4Sorting algorithms: bubble, insertion and merge sortOpen in Full Marks · 31 questions
  5. 6.5Comparing the efficiency of algorithmsOpen in Full Marks · 23 questions

6.1 · Free notes

Writing algorithms in pseudocode and flowcharts (exam reference languages)

Diagram: Writing algorithms in pseudocode and flowcharts (exam reference languages)

Key points

In more detail

Practice

Writing algorithms in pseudocode and flowcharts (exam reference languages): 10 questions

Pick an answer to check it, or open the answer for the explanation.

1. Which flowchart symbol is used for a decision such as 'Is n > 10?'

  1. Parallelogram
  2. Rectangle
  3. Diamond
  4. Oval
Show answer

C: Diamond. A diamond represents a decision and has two labelled exits (Yes/No). Rectangles are processes, parallelograms are input/output and ovals are start/end.

2. Which flowchart symbol is used to show data being input or output?

  1. Rectangle
  2. Diamond
  3. Oval
  4. Parallelogram
Show answer

D: Parallelogram. A parallelogram is the standard symbol for input and output. A rectangle is a process, an oval marks start or end, and a diamond is a decision.

3. What is the value of 23 MOD 5?

  1. 4
  2. 18
  3. 5
  4. 3
Show answer

D: 3. MOD returns the remainder. 23 = 4 × 5 + 3, so 23 MOD 5 = 3. The value 4 is 23 DIV 5.

4. What is the value of 23 DIV 5?

  1. 4.6
  2. 4
  3. 5
  4. 3
Show answer

B: 4. DIV gives the whole-number part of the division: 5 goes into 23 four times, so 23 DIV 5 = 4. The remainder (3) is what MOD gives.

5. Which iteration structure always executes its body at least once?

  1. IF ... ENDIF
  2. FOR ... ENDFOR
  3. WHILE ... ENDWHILE
  4. REPEAT ... UNTIL
Show answer

D: REPEAT ... UNTIL. REPEAT ... UNTIL tests its condition after the body, so the body runs once before any test. WHILE tests first and may never run. IF is selection, not iteration.

6. A program must keep asking for a password until the user types the correct one. Which structure suits this?

  1. Sequence only
  2. A condition-controlled loop
  3. A count-controlled FOR loop
  4. A single IF statement
Show answer

B: A condition-controlled loop. The number of attempts is unknown, so a condition-controlled loop (WHILE or REPEAT) that ends when the password is correct is needed. FOR needs a known count.

7. What is output? total ← 0 FOR i ← 1 TO 4 total ← total + i ENDFOR OUTPUT total

  1. 6
  2. 4
  3. 15
  4. 10
Show answer

D: 10. The loop runs for i = 1, 2, 3 and 4 and adds each to total: 1 + 2 + 3 + 4 = 10. The end value 4 is included.

8. In AQA pseudocode, how many times does FOR i ← 0 TO 5 repeat its body?

  1. 7
  2. 5
  3. 6
  4. 4
Show answer

C: 6. A FOR loop includes both the start and the end value. i takes 0, 1, 2, 3, 4 and 5, which is 6 iterations.

9. Which of the following is NOT one of the three basic programming constructs?

  1. Compilation
  2. Selection
  3. Sequence
  4. Iteration
Show answer

A: Compilation. The three constructs are sequence, selection and iteration. Compilation is the translation of source code into machine code, not a construct for building algorithms.

10. How should a decision symbol in a correct flowchart be drawn?

  1. One entry and two labelled exits
  2. One entry and one unlabelled exit
  3. Two entries and no exits
  4. One entry and three unlabelled exits
Show answer

A: One entry and two labelled exits. A decision asks a yes/no question, so it has one flow line in and two labelled flow lines out (Yes/No or True/False).

Keep going in Full Marks

Full Marks has 20 questions on Writing algorithms in pseudocode and flowcharts (exam reference languages) (10 more than here), set out in practice levels. You also get notes and 3D models for all 5 subtopics of Algorithms: representation, searching and sorting, plus games, timed exams and past papers.

On your exam board

All GCSE Computer Science topics