0% found this document useful (0 votes)
15 views

Algorithm Is Fun

The document contains algorithms and questions about algorithms from past exam papers between 2002-2009. The algorithms deal with topics like sorting numbers, calculating statistics from transactions, calculating time spent online, calculating BMI, and sorting students into categories based on test scores or BMI. Questions assess understanding of algorithm structure and logic, like tracing algorithms, explaining purposes of variables, and explaining why algorithms are written as subroutines.

Uploaded by

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

Algorithm Is Fun

The document contains algorithms and questions about algorithms from past exam papers between 2002-2009. The algorithms deal with topics like sorting numbers, calculating statistics from transactions, calculating time spent online, calculating BMI, and sorting students into categories based on test scores or BMI. Questions assess understanding of algorithm structure and logic, like tracing algorithms, explaining purposes of variables, and explaining why algorithms are written as subroutines.

Uploaded by

Tkinter Mastery
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 37

M/J 2002

8. (b) A procedure (subroutine) called BELT exists to take one box and put it on a conveyor
belt. Write an algorithm, using this procedure, to put 50 boxes on the conveyor belt.

16 Using pseudo code or otherwise, write an algorithm which will take information about each
transaction at a supermarket till, calculate and output
• the number of sales,
• the number of refunds,
• the total amount of money in the till.

M/J 2003
13 Read this algorithm.
input A, B
if A > B then
T=A
A=B
B=T
endif
output A, B

(a) Write down the output if the following two numbers are input:
41, 38
.....................................................................................................................................[1]
(b) Explain the purpose of the variable T.
.........................................................................................................................................
.....................................................................................................................................[1]
(c) Explain why an algorithm is written as a subroutine (procedure) and stored in a program
library.
.........................................................................................................................................
.........................................................................................................................................
.........................................................................................................................................
.....................................................................................................................................[2]

17 A school wants to monitor the number of hours spent by a class of 30 students on the
Internet.
Using pseudocode or otherwise, write an algorithm which will;
• for each student, record the times logged on and logged off
• calculate the length of time each student spends online
• calculate and output the average length of time per day spent by each student on the
Internet.
M/J 2004
15
M/J 2005
13 (a) The following algorithm contains an error.
1. SET X = 1
2. REPEAT
3. X = X + 2
4. Print X
5. UNTIL X = 10
(a) Trace the algorithm and explain what the error is.

(b) Write an algorithm which uses a While..Do..Endwhile loop and outputs the numbers 2, 4, 6
and 8.

17 Using pseudocode or otherwise, write an algorithm that will input 25 marks and output the
number of DISTINCTION, MERIT, PASS or FAIL grades.
A mark greater than 69 will get a DISTINCTION, a mark between 69 and 60 (inclusive) will
get a MERIT and a mark between 59 and 50 (inclusive) will get a PASS.
M/J 2006
9

Trace the flow chart using the numbers 2 and 3. Write down each of the values of N in the order that
they are printed out.

16 (b)

Using pseudocode or otherwise, write an algorithm that will input the ID, weight (kg) and
height (m) of 30 students, calculate their body mass index (BMI) and output their ID,
BMI and a comment as follows:

A BMI greater than 25 will get the comment ‘OVER WEIGHT’, a BMI between 25 and
19 (inclusive) will get ‘NORMAL’ and a BMI less than 19 will get ‘UNDER WEIGHT’.
M/J 2007
11

19
M/J 2008
9
12

19
M/J 2009
14
16
18
O/N 2001
10
11
14

15
16
O/N 2002
13
18
19
O/N 2003
11
15
16
O/N 2004
12
[6]
O/N 2005
9
17
O/N 2006
9
17
20
O/N 2007
16
17
O/N 2008
3
17
19
O/N 2009
9
17
17

You might also like