An array is an Abstract Data Type (ADT).
- (a)Identify two other ADTs. 1 2[1]
- (b)A 1D array DataArray holds up to 1000 elements of type integer and needs to be sorted in ascending order. Write the pseudocode for an insertion sort to sort the array into ascending order. Use the identifiers from the table in your algorithm. You do not need to declare any arrays or variables for this algorithm. You may assume this has already been done. Identifier | Data type | Description ---|---|--- Index | INTEGER | counter for outer loop Position | INTEGER | counter for inner loop – insertion position DataArray | INTEGER | 1D array to store up to 1000 integers Value | INTEGER | value to insert The first line has been written for you. FOR Index ← 2 to 1000[4]
- (c)Describe two ways in which the performance of a sort routine is affected by the data to be sorted. 1 2[2]
Mark scheme
Marking points from the official mark scheme (May/June 2025). The mark or mark type is shown in brackets.
- [1] One mark for any two correct ADTs (Max 1)
- • Binary tree
- • Graph
- • Linked list
- • Queue
- • Stack
- [4] One mark for each marking point (Max 4)
- MP1 Temporary assignment of the element being 'inserted' before inner loop
- MP2 Appropriate inner loop
- MP3 Check if current DataArray content is > Value
- MP4 Moving data to adjacent element as required
- MP5 Appropriate updating of Position variable
- MP6 Re-insertion of the element outside the inner loop
- Example algorithm: FOR Index ← 2 to 1000 Value ← DataArray[Index] Position ← Index - 1 IF DataArray[Position] > Value THEN WHILE Position >= 1 AND DataArray[Position] > Value DataArray[Position + 1] ← DataArray[Position] Position ← Position - 1 ENDWHILE DataArray[Position + 1] ← Value ENDIF NEXT Index
- [2] One mark for each marking point
- MP1 The performance of a sorting routine should improve if the data is already partially sorted // The performance of a sorting routine is likely to be worse if the data is completely out of order
- MP2 The sort may take longer if the number of items to be sorted is larger // The sort may take less time if the number of items to be sorted is fewer.
Write your answer and get it marked
On Oracle Prep you can write or photograph your own answer and have it marked by AI against this mark scheme, with feedback on what you missed.
Sign up free →