0% found this document useful (0 votes)
2 views1 page

Form4 AlgorithmDesign

Uploaded by

chanelcee13
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

Form4 AlgorithmDesign

Uploaded by

chanelcee13
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

SOLID ROCK SCHOOL

Computer Science Department

Form 4 Computer Science — Algorithm Design


Answer ALL questions on a separate answer sheet. | Total: 10 marks

Name: ___________________________________ Class: ____________ Date: _______________

SECTION A: Understanding Algorithms

1. Define the term algorithm and state THREE properties that every well-designed algorithm must have. [2
marks]
2. Study the pseudocode below and trace its output when x = 4. [1 mark]
SET x = 4
SET result = 1
FOR i = 1 TO x
SET result = result * i
ENDFOR
OUTPUT result

SECTION B: Flowcharts

3. Name FOUR standard flowchart symbols and state the purpose of each. [2 marks]
4. Draw a flowchart for an algorithm that asks the user to enter a number, checks whether it is even or odd, and
outputs an appropriate message. [1 mark]

SECTION C: Pseudocode

5. Write pseudocode for an algorithm that reads 5 numbers from the user and outputs their sum and average.
Your solution must use a loop. [2 marks]
6. The pseudocode below contains TWO logic errors. Identify both errors and write the corrected lines. [1 mark]
INPUT score
IF score > 50 THEN
OUTPUT "Fail"
ELSE
OUTPUT "Pass"
ENDIF

SECTION D: Searching and Sorting

7. The list below is to be sorted into ascending order using the bubble sort algorithm. Show the state of the list
after EACH complete pass until no swaps are needed. [2 marks]
[ 7, 3, 9, 1, 5 ]
8. Compare linear search and binary search by stating: (i) how each works in one sentence, (ii) ONE condition
required before binary search can be applied. [1 mark]

SECTION E: Algorithm Efficiency and Testing

9. An algorithm is designed to find the largest number in a list of n values. Write pseudocode for this algorithm.
State the number of comparisons made for a list of 8 values. [2 marks]
10. Explain what is meant by a trace table and describe how it is used to test whether an algorithm is correct.
State the type of error a trace table helps to detect. [1 mark]

— END OF QUESTION PAPER —

You might also like