Define decomposition. [2]
Tap/click to reveal
Breaking down a complex problem into smaller subtasks ✓
and solving each one individually ✓
Example 1 shows an algorithm written in pseudo-code.
Example 1
height ← USERINPUT
width ← USERINPUT
area ← height * width
OUTPUT area
Describe what the code in Example 1 does. [3]
Tap/click to reveal
Takes in the height and width as input, ✓
multiplies them together, ✓
and outputs the resulting area ✓
A parcel number is valid if it has exactly 8 characters.
Write an algorithm in pseudo-code to output whether or not a parcel number is valid. [5]
Tap/click to reveal
number ← USERINPUT ✓
IF LEN(number) = 8 THEN ✓
OUTPUT "Valid" ✓
ELSE
OUTPUT "Invalid" ✓
ENDIF ✓
Diagram 1 shows a flowchart of an algorithm.
Diagram 1
What is the mistake in Diagram 1? [1]
Tap/click to reveal There should be a box to input "miles" ✓
Why can a binary search not be used on the list
[2, 3, 5, 7, 13, 11]? [1]
Tap/click to reveal The list is not sorted ✓
Describe the stages of a binary search to find the string
"ford" in the list ["audi", "bmw", "ford", "mercedes", "tesla", "toyota", "volkswagen"]. [3]
Tap/click to reveal
Compare "ford" to "mercedes" (the middle item). "ford" is smaller, so take only the left half ✓
Compare "ford" to "bmw" (the new middle item). "ford" is greater, so take only the right half ✓
Compare "ford" to "ford" (the new middle item). They are equal, so stop searching ✓
Explain two benefits of using bubble sort over merge sort. [4]
Tap/click to reveal
In bubble sort, all the sorting is done on the original list ✓
and therefore bubble sort uses less memory than merge sort ✓
Merge sort always goes through the whole splitting and merging process, whereas bubble sort exits early once the list is sorted ✓
so bubble sort is quicker for lists which are nearly ordered already ✓
Why does merge sort split the list into single items, then merge them [2]
Tap/click to reveal
Smaller lists are easier to sort than larger lists ✓
Ordered lists are easier to merge and sort than unordered lists ✓