1. What is the primary purpose of an 4. What is the primary purpose of algorithm
algorithm? analysis? a) To perform a sequence of steps a) To determine the efficiency of an b) To solve a specific problem algorithm c) To store data b) To find the optimal solution d) Both a and b c) To implement the algorithm 2. Which of the following is not a d) To understand the problem fundamental characteristic of an algorithm? 5. What is the difference between an a) Finiteness algorithm and a program? b) Definiteness a) An algorithm is a set of steps, while a c) Ambiguity program is a set of instructions d) Effectiveness b) An algorithm is written in pseudocode, 3. What is the correct order of the steps in while a program is written in a programming the algorithm design process? language a) Problem understanding, algorithm c) An algorithm is a high-level solution, design, implementation, testing while a program is a low-level b) Problem understanding, implementation implementation, algorithm design, testing d) All of the above c) Implementation, problem 6. What is the primary purpose of the understanding, algorithm design, testing pseudocode in algorithm representation? d) Problem understanding, testing, a) To provide a detailed, step-by-step algorithm design, implementation implementation b) To provide a high-level, abstract c) Draw a flowchart to represent the representation of the algorithm above algorithm (2 marks) c) To provide a visual representation of the d) Define the term Flowchart (1 mark) algorithm e) Describe the three control structures d) To provide a formal mathematical used in algorithms (3 marks) representation of the algorithm f) Write an algorithm that can be used 7. Which of the following is not a common to determine if a mark entered is way to represent an algorithm? positive or negative. The algorithm a) Flowchart should receive the mark from the b) Pseudocode user, then return “1” if the mark is c) Programming language positive, or “0” if otherwise. (2 d) Mathematical notation marks) 8) Consider the algorithm below g) Write an algorithm to calculate the
Algorithm factorial (n!) of an integer entered by
Var sum, i, number, size: integer; the user. Your program should take note that 1! = 1 And 0! = 1 (3 marks) Begin Write(“How many numbers do you want to sum”); Read(size); Write(“Enter the numbers one after another”); For(i=0 to i<=size) do Read(number); Sum = sum + number; endfor Write(“The sum of your numbers is”, sum); End
a) What does the above algorithm do?
(1 mark) b) What will be the content of the variable sum at the end of the execution, if the user enters the size = 5, followed by the numbers, 4, 3, 2, 5, ? (1 marks)