May/June 2026 Paper 42

2026 · 3 questions · 24 parts · 75 marks

0/75 marks
0Correct0Partial0Wrong24Unattempted
Filters0 active
Context for question 1
A program stores nine lower-case strings in a 1D array called TheData. The following strings are stored in the order shown:
text
laptoptabletprintercomputerprocessormonitormemorycabletouchscreen
1(a)ArraysEasy2 marks
Write program code to declare the array TheData in the main program. Store the given strings in the array.

Answer

0 words
1(b)(i)ArraysMedium5 marks
The procedure FindLongestShortest():
  • takes an array of strings as a parameter
  • finds and outputs the longest string in the array of strings
  • finds and outputs the shortest string in the array of strings.
All outputs must have appropriate messages. Do not use in-built functions to find the longest and shortest string in the array. You may use an in-built length function to find the length of a string.
You can assume that there will only be one string that has the shortest length, and only one string that has the longest length.
Write program code for FindLongestShortest().

Answer

0 words
1(b)(ii)Subroutines Scope Modular ProgrammingEasy1 mark
Write program code to extend the main program to call FindLongestShortest() with TheData.

Answer

0 words
1(b)(iii)ArraysEasy1 mark
Run your program.
Describe exactly what your program outputs, in the order it is produced.

Answer

0 words
1(c)(i)Sorting AlgorithmsMedium5 marks
The function InsertionSort():
  • takes an array of strings as a parameter
  • sorts the strings in the array into ascending alphabetical order using an insertion sort
  • returns the sorted array.
The function must work for an array of any length. Do not use an in-built function to sort the array.
Write program code for InsertionSort().

Answer

0 words
1(c)(ii)Sorting AlgorithmsMedium3 marks
Write program code to extend the main program to perform the following, in the order shown:
  • output the string "Before sorting"
  • output the contents of the array TheData
  • call InsertionSort() with TheData as a parameter
  • output the string "After sorting"
  • output the contents of the returned sorted array.

Answer

0 words
1(c)(iii)Sorting AlgorithmsEasy1 mark
Run your program.
Describe exactly what your program outputs, in the order it is produced.

Answer

0 words