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 »
Write the steps of the bubble sort algorithm used to sort an array in ascending order.
Bubble Sort Algorithm Steps (4 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 »
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 »
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 »
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 »
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 »
Write a pseudocode segment for a program that asks the user to enter a positive integer. If the number is even, it should output “Even Number Entered”, otherwise it should output “Odd Number Entered”. You should check that the entered number is positive and prompt the user again if not.
Writing Algorithms: WHILE Loop (5 marks) Read More »
Consider a one-dimensional array temperatures that stores weekly temperature data. An algorithm is required to find the highest temperature in the array and its corresponding day of the week. Write pseudocode to perform this task. The days of the week are represented as an array of strings days [“Mon”, “Tue”, “Wed”, “Thu”, “Fri”, “Sat”, “Sun”].
Writing Algorithms that uses an Array (5 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 »
Notifications