Skip to content

Course home

Sorting algorithms

Sorting algorithms

EasyMediumHard
123456789101112131415161718192021222324252627
Question 4

Select one option to show which of the following contains the false statement about the algorithm shown in the pseudocode below.

1  arr ← [15, 3, 12, 6, 19]
2  FOR i ← 1 TO 4
3      key ← arr[i]
4      j ← i - 1
5      WHILE j >= 0 AND arr[j] > key
6          arr[j + 1] ← arr[j]
7          j ← j - 1
8      ENDWHILE
9      arr[j + 1] ← key
10 ENDFOR
A

The algorithm performs an in-place sort, meaning it does not copy the elements into a new, separate array.

B

After the outer loop completes its first iteration (when i=1i = 1i=1), the state of the array arr is [3, 15, 12, 6, 19].

C

The outer loop represents indefinite iteration because the total number of passes depends on the initial order of the elements in the array.

D

The inner loop uses indefinite iteration and terminates either when an element less than or equal to key is encountered, or when j<0j < 0j<0.

Markscheme

Sorting algorithms Questions

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

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.

Question bank