Binary Search Precondition (2 Marks)
What is a precondition for using a binary search algorithm on an array, and why is this precondition necessary?
Binary Search Precondition (2 Marks) Read More »
What is a precondition for using a binary search algorithm on an array, and why is this precondition necessary?
Binary Search Precondition (2 Marks) Read More »
Explain the concept of the ‘divide and conquer’ strategy as used in the merge sort algorithm.
Merge Sort Concept (2 Marks) Read More »
Explain the difference between a syntax error and a runtime error.
Syntax vs Run-Time (2 marks) Read More »
Identify three types of logic errors that can occur in a program.
Logic Errors (3 marks) Read More »
Given the following algorithm fragment in pseudocode: SET x TO 5 SET y TO x + 2 SET x TO y + 3 What is the value of x at the end of the execution?
Reading Algorithms: Assignment (1 marks) Read More »
Describe how a linear search algorithm works to find a target value in a one-dimensional array.
Explain Linear Search Algorithm (2 Marks) Read More »
Consider the following pseudocode for an algorithm: SET total TO 0 FOR i FROM 1 TO 5 DO SET total TO total + i END FOR What will be the value of total after the loop has finished execution? Show your working / calculation for each iteration.
Reading Algorithms: FOR Loop (2 marks) Read More »
A simple algorithm in pseudocode is given below: FUNCTION CalculateTotal(numbers) SET sum TO 0 FOR EACH number FROM numbers DO SET sum TO sum + number END FOR RETURN sum END FUNCTION A student executed the algorithm using the list [3, 7, 2, 5]. Determine the final value returned by the CalculateTotal function. Show your
Reading Algorithms: Function and FOR Loop (3 marks) Read More »
An algorithm uses a counter count and a total accumulator total. The algorithm adds up numbers from 1 to a given limit. The pseudocode is as follows: SET count TO 1 SET total TO 0 WHILE count
Reading Algorithms: WHILE Loop (2 marks) Read More »
An array of student scores needs to be analysed to determine how many students scored more than 50 marks. The array scores contains the following data: [45, 62, 33, 55, 90, 49]. Write pseudocode that: Sets up a counter for scores above 50. Uses iteration to count how many students scored above 50. Outputs the
Writing Algorithms: Arrays (5 marks) Read More »