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 |
Practise AQA GCSE Computer Science Sorting algorithms with exam-style questions for GCSE Computer Science. 62 questions, matched to the AQA GCSE Computer Science (8525) specification and written in Paper 1 and Paper 2 style. Every question includes a full worked solution and mark scheme, so you can see where marks are awarded rather than just whether you got the answer right.