IGCSE · Computer Science 0478 · Algorithms & programming

Arrays: IGCSE Computer Science questions with answers

Free Arrays questions for IGCSE Computer Science (0478), part of Algorithms & programming. Each question has the answer and the marking points an examiner would look for.

Generate a full Arrays worksheet →All Algorithms & programming questions

Arrays practice questions

Question 1Structured · 5 marks

A program uses a bubble sort to put the array Values[1:6] into ascending order. Before sorting, the array contains:
3 21 52 24 18 36

(a)

Write the contents of the array after the first pass of the bubble sort.

[2]
(b)

State the number of swaps made in the first pass.

[1]
(c)

Explain how the algorithm knows the array is sorted, so that it can stop early.

[2]
Show answers and mark scheme
PartAnswer and marking pointsMarks
(a)3 21 24 18 36 52
3 21 24 18 36 52 B2
B1 if only one adjacent pair of values is in the wrong order
2
(b)3
3 B1
1
(c)A flag records whether any swap was made in a pass; if a complete pass makes no swaps the array is sorted
Uses a flag / Boolean variable set when a swap happens B1
Stops when a whole pass completes with no swaps B1
2
Question 2Structured · 6 marks

A one-dimensional array ItemCode[1:20] stores 20 values of data type STRING.

Write an algorithm in pseudocode to search the array for an item code input by the user and output the index of the code, or "Not found".

[6]
Show answers and mark scheme
PartAnswer and marking pointsMarks
Input target; Found ← FALSE; loop through the array (FOR or conditional loop); IF element = target store index and set Found ← TRUE; output index or "Not found"
INPUT target value B1
Flag / position initialised (e.g. Found ← FALSE) B1
Loop through elements 1 to 20 (may stop when found) B1
Compare ItemCode[Index] with the target B1
Store the index / set the flag when found B1
Output the position, or "Not found" if the flag is still FALSE B1
6
Question 3Structured · 6 marks

A two-dimensional array Score[1:30, 1:4] stores the test scores for each of 30 students. The array has already been filled with whole numbers.

Write an algorithm in pseudocode to output the total for each row of the array, and then output the largest of these totals.

[6]
Show answers and mark scheme
PartAnswer and marking pointsMarks
Largest ← 0; FOR Row ← 1 TO 30; Total ← 0; FOR Col ← 1 TO 4; Total ← Total + Score[Row, Col]; NEXT Col; OUTPUT Total; IF Total > Largest THEN Largest ← Total ENDIF; NEXT Row; OUTPUT Largest
Largest initialised before the outer loop (to 0 or to the first total) B1
Outer loop 1 to 30 with Total reset to 0 inside it B1
Inner loop 1 to 4 B1
Total ← Total + Score[Row, Col] with indices in the correct order B1
OUTPUT Total after the inner loop, inside the outer loop B1
Compare and update Largest; OUTPUT Largest after both loops B1
6
Question 4Structured · 2 marks

State what is meant by the term array.

[2]
Show answers and mark scheme
PartAnswer and marking pointsMarks
A data structure holding a fixed number of elements of the same data type under one identifier
A data structure holding a fixed number of elements of the same data type under one identifier B2
2
Question 5Structured · 5 marks

A program uses a bubble sort to put the array Values[1:6] into ascending order. Before sorting, the array contains:
52 12 9 44 36 15

(a)

Write the contents of the array after the first pass of the bubble sort.

[2]
(b)

State the number of swaps made in the first pass.

[1]
(c)

Explain how the algorithm knows the array is sorted, so that it can stop early.

[2]
Show answers and mark scheme
PartAnswer and marking pointsMarks
(a)12 9 44 36 15 52
12 9 44 36 15 52 B2
B1 if only one adjacent pair of values is in the wrong order
2
(b)5
5 B1
1
(c)A flag records whether any swap was made in a pass; if a complete pass makes no swaps the array is sorted
Uses a flag / Boolean variable set when a swap happens B1
Stops when a whole pass completes with no swaps B1
2
Question 6Structured · 5 marks

A one-dimensional array Score[1:25] stores 25 values of data type INTEGER.

Write an algorithm in pseudocode to search the array for a score input by the user and output how many times the score appears in the array.

[5]
Show answers and mark scheme
PartAnswer and marking pointsMarks
Input target; Count ← 0; FOR loop 1 to 25; IF element = target THEN Count ← Count + 1; output Count
INPUT target value B1
Count initialised to 0 B1
FOR loop from 1 to 25 B1
IF Score[Index] = target THEN Count ← Count + 1 B1
OUTPUT Count after the loop B1
5

More Algorithms & programming questions

Want a mentor, not just a paper?

Riyaz Shaikh has mentored IGCSE, IB and A Level students for 15+ years, one-on-one, online and in Mumbai. The hardest questions on this site are the ones he uses to find a student's weak points.

Meet Riyaz →

Original Cambridge-style practice questions written for mentorriyaz.in. These are not Cambridge past paper questions, and this site is not affiliated with or endorsed by Cambridge University Press & Assessment. Updated 2026-11-04. Paper generator · mentorriyaz.in