Sorting algorithms

EasyMediumHard
12345678910111213141516171819202122232425262728293031323334353637
Question 13
Medium

Complete the trace table for the algorithm shown below. Some values have already been entered. You may not need to use all the rows in the table.

1  list[0] ← 1
2  list[1] ← 5
3  list[2] ← 8
4  FOR p ← 0 TO 1
5      FOR q ← 0 TO 1
6          IF list[q] < list[q + 1] THEN
7              val ← list[q]
8              list[q] ← list[q + 1]
9              list[q + 1] ← val
10         ENDIF
11     ENDFOR
12 ENDFOR
list[0]list[1]list[2]pqval
158
[6]

Sorting algorithms Questions

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