Sorting algorithms

EasyMediumHard
12345678910111213141516171819202122232425262728293031323334353637
Question 6
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  arr[0] ← 8
2  arr[1] ← 5
3  arr[2] ← 2
4  FOR i ← 0 TO 1
5      FOR j ← 0 TO 1
6          IF arr[j] > arr[j + 1] THEN
7              temp ← arr[j]
8              arr[j] ← arr[j + 1]
9              arr[j + 1] ← temp
10         ENDIF
11     ENDFOR
12 ENDFOR
arr[0]arr[1]arr[2]ijtemp
852
[6]

Sorting algorithms Questions

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