Skip to content

Course home

Representing algorithms

Representing algorithms

EasyMediumHard
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
Question 25

An algorithm is designed to sort a list of three elements in descending order.

Complete the trace table for this algorithm shown in Figure 1.

Some values have already been entered. You may not need to use all the rows in the table.

Figure 1

1  A[0] ← 5
2  A[1] ← 14
3  A[2] ← 9
4  FOR p ← 0 TO 1
5      FOR q ← 0 TO 1
6          IF A[q + 1] > A[q] THEN
7              hold ← A[q]
8              A[q] ← A[q + 1]
9              A[q + 1] ← hold
10         ENDIF
11     ENDFOR
12 ENDFOR

Trace Table

A[0]A[1]A[2]pqhold
5149
[6]
Markscheme

Representing algorithms Questions

  1. GCSE
  2. /Computer Science
  3. /Representing algorithms

208 exam-style questions on AQA GCSE Computer Science Representing algorithms. Each one has a worked solution and a mark scheme showing where the marks go.

Question bank