A marine research drone records underwater depth measurements at three specific coordinates. The initial depth readings are stored in an array depth of size 3 as follows: depth[0] = 4, depth[1] = 11, and depth[2] = 15 (in meters).
An algorithm is run to sort these depths in descending order:
1 depth[0] ← 4
2 depth[1] ← 11
3 depth[2] ← 15
4 FOR i ← 0 TO 1
5 FOR j ← 0 TO 1
6 IF depth[j] < depth[j + 1] THEN
7 temp ← depth[j]
8 depth[j] ← depth[j + 1]
9 depth[j + 1] ← temp
10 ENDIF
11 ENDFOR
12 ENDFOR
Complete the trace table for this algorithm. Some values have already been entered. You may not need to use all the rows in the table.
| depth[0] | depth[1] | depth[2] | i | j | temp |
|---|---|---|---|---|---|
| 4 | 11 | 15 |
52 exam-style questions on AQA GCSE Computer Science Sorting algorithms. Each one has a worked solution and a mark scheme showing where the marks go.