Score: 0/0

Question 1 of ∞

Define decomposition. 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. Takes in the height and width as input Multiplies them together 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. 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? 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]? 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"]. 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. In bubble sort, all the sorting is done on the original list 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? Smaller lists are easier to sort than larger lists Ordered lists are easier to merge and sort than unordered lists