ExamBank Scot · AH Computing Science question bank · All AH Computing Science questions

AH Computing Science 2026 Question 1

3 marks · Linked lists

Describe one difference between an array and a linked list. The comparisons at steps 1, 2, 3 and 4 in the first pass of this bubble sort are shown below. Step Comparison 1 Compare 12 and 14 → no swap → [12, 14, 2, 5, 7, 19, 15, 5, 7] 2 Compare 14 and 2 → swap → [12, 2, 14, 5, 7, 19, 15, 5, 7] 3 Compare 14 and 5 → swap → [12, 2, 5, 14, 7, 19, 15, 5, 7] 4 Compare 14 and 7 → swap → [12, 2, 5, 7, 14, 19, 15, 5, 7] 5 6 7 8 Describe the comparisons that take place at steps 5, 6, 7 and 8 in the first pass of the bubble sort algorithm. Your description should include the level of detail provided for steps 1–4. The contents of the 1‑D array [12, 14, 2, 5, 7, 19, 15, 5, 7] are to be sorted in ascending order using the bubble sort algorithm.

Marking scheme

Arrays have a fixed size, which must be defined at the time of creation whereas linked lists allow dynamic memory allocation, meaning they can grow or shrink in size as needed. An Array is a collection of elements stored in contiguous memory locations which allows random access to elements using an index; a linked list is a collection of nodes where each node contains a data element and a reference (or pointer) to the next node in the sequence. Award 1 mark for either comparison point. Must be a valid comparison. See sample solution below. Award 1 mark for steps 5 & 6 correct. Award 1 mark for steps 7 & 8 correct. 5. Compare 14 and 19 → no swap → [12, 2, 5, 7, 14, 19, 15, 5, 7] 6. Compare 19 and 15 → swap → [12, 2, 5, 7, 14, 15, 19, 5, 7] 7. Compare 19 and 5 → swap → [12, 2, 5, 7, 14, 15, 5, 19, 7] 8. Compare 19 and 7 → swap → [12, 2, 5, 7, 14, 15, 5, 7, 19]

Previous question: AH Computing Science 2025 Question 10

Next question: AH Computing Science 2026 Question 2