9.2 Algorithms
31 questions in this subtopic. Open a question to solve it and check the official answer.
Algorithms · 5 marks · official answer ready
2 Data is a global 1D array containing 30 elements of type STRING An algorithm will output: • all non-blank elements (elements that do not contain an empty string) • the final tot…
Algorithms · 6 marks · official answer ready
(a) Complete the pseudocode for Store() All variables used in the algorithm must be declared. PROCEDURE Store() ...................................................................…
Algorithms · 5 marks · official answer ready
(b) The pseudocode represents an algorithm to set the appropriate elements of the array to TRUE Complete the pseudocode: DECLARE EasyQ, HardQ : INTEGER FOR EasyQ .................…
Algorithms · 6 marks · official answer ready
2 (a) A program contains a global 1D array of type STRING containing 65 elements. An existing text file is used to store the data in the array. Only non-blank elements (those that…
Algorithms · 18 marks
(a) A text file Sales.txt stores strings representing the number of items sold. The file contains 52 lines, each representing the number of items sold in each week of the year. Fo…
Algorithms · 5 marks · official answer ready
(a) Write pseudocode for the algorithm. Assume the value zero is neither positive nor negative. You must declare all variables used in the algorithm. .............................…
Algorithms · 4 marks · official answer ready
(b) The array List will be initialised so that each node points to the following node. The last node will contain a null pointer. Complete the program flowchart to represent the a…
Algorithms · 4 marks · official answer ready
(c) An algorithm outputs the Data field from all nodes in the array List. The order the Data is output should be the same order it is stored in the linked list. Describe the algor…
Algorithms · 5 marks · official answer ready
(b) A different part of the program contains an algorithm represented by the following program flowchart: START Set Flag to GetStat() Is Flag = Yes TRUE ? No END Set Port to 1 No …
Algorithms · 2 marks · official answer ready
(i) State two benefits of this modification to the existing program. 1 ............................................................................................................…
Algorithms · 2 marks · official answer ready
(c) Describe the performance of a binary search in relation to the number of data items in the array being searched. Refer to Big O notation in your answer. ......................…
Algorithms · 8 marks
8 (a) Complete the pseudocode to find an item in a 1D array Widgets of type STRING, using a linear search. DECLARE Widgets : ARRAY[1:50000] OF STRING DECLARE TopOfList : INTEGER D…
Algorithms · 8 marks · official answer ready
8 (a) Complete the pseudocode to find an item in a 1D array Widgets of type STRING, using a linear search. DECLARE Widgets : ARRAY[1:50000] OF STRING DECLARE TopOfList : INTEGER D…
Algorithms · 2 marks · official answer ready
(c) Describe the performance of a binary search in relation to the number of data items in the array being searched. Refer to Big O notation in your answer. ......................…
Algorithms · 5 marks · official answer ready
(a) Draw a program flowchart to represent the algorithm. START END [5] 5
Algorithms · 5 marks · official answer ready
(a) An algorithm will output the index of the element with the smallest value. Draw a program flowchart to represent the algorithm. START END [5] 5
Algorithms · 1 mark · official answer ready
(c) The pseudocode does not include a declaration for PCount. State the data type that should be used in the declaration. .........................................................…
Algorithms · 5 marks · official answer ready
(ii) A module SaveStack() will write the data from the stack to a text file. Express an algorithm for SaveStack() as five steps that could be used to produce pseudocode. Write the…
Algorithms · 5 marks · official answer ready
(i) Describe the steps that the algorithm should perform. Do not include pseudocode statements in your answer. ....................................................................…
Algorithms · 6 marks · official answer ready
(a) Write the equivalent pseudocode for the algorithm represented by the flowchart. ...............................................................................................…
