2.1 Algorithm Design and Problem-Solving PDF
2.1 Algorithm Design and Problem-Solving PDF
Oct/Nov 2006
Oct/Nov 2006
11 A school keeps a spreadsheet of examination results in four subjects. Part of the spreadsheet is
shown below.
(e) State the validation check that should be carried out on data entered in cells C2 to F8 to
ensure values over 100 are not input.
Page 1 of 97
Computer Science 2210
Topical Past Papers
Oct/Nov 2007
15 A school Science department is going to use a database to record details about its
equipment.
(b) Part of the database is shown below:
(i) As data is entered it needs to be verified. Describe one way this could be done. [1]
(ii) Data also needs to be validated. Using fields from the database as examples,
Describetwodifferent validation checks which could be performed on the data.
May/June 2008
5 Computer systems can be affected by viruses.
(d) Examination results are stored in students’ records as marks out of 100. Give two different
validation checks that could be performed on students’ marks.
6
(d) Examination results are stored in students’ records as marks out of 100. Give two different
validation checks that could be performed on students’ marks. [2]
Page 2 of 97
Computer Science 2210
Topical Past Papers
(d) Name a different validation check for each of the following fields.
(i) Maximum surface temperature (0C)
(ii) Name of planet
Oct/Nov 2009
1 Explain, using examples where appropriate, the meaning of these computer terms.
(e) validation
Page 3 of 97
Computer Science 2210
Topical Past Papers
15 A database has been set up to bring together information about the world’s tallest buildings.
A section of the database is shown below.
(d) For each of the following fields give a different validation check.
Year
Ref No.
15 A college secretary inputs data into fields on a computer screen as shown below:
Page 4 of 97
Computer Science 2210
Topical Past Papers
1. Explain, with examples where appropriate, the following five computer terms.
(d) Verification
16 A customer logs on to a secure website using a code and a password. The first stage is tokey in
a code which is his date of birth (DDMMYY) followed by 1234. The second stage isto type in the
first, third, fourth and seventh character of his password.
7 A spreadsheet has been set up to compare the costs of types of fruit juice sold by a shop.
Page 5 of 97
Computer Science 2210
Topical Past Papers
(b) (i) Name a validation check that could be used ontheCustomer ID field? [1]
(ii) Describe TWO types of test data, together withexamples, that could be used to see
whetherthe validation check named in (i) works.
Page 6 of 97
Computer Science 2210
Topical Past Papers
4 Five definitions and descriptions are shown below on the left hand side.
Five computer terms are shown on the right.
Match the definitions/descriptions on the left to the correct term on the right by drawing
connecting arrows.
Page 7 of 97
Computer Science 2210
Topical Past Papers
c=0
INPUT PIN
x = PIN
REPEAT
x = x/10
c = c + 1
UNTIL x < 1
IF c < 5
THEN
PRINT “error in PIN entered”
ELSE
PRINT “PIN OK”
ENDIF
(i) What value of c and what message would be output if the following PINs were entered?
5 1 0 2 0 Value of c:
Message:
5 1 2 0 Value of c:
Message: [2]
(ii) What type of validation check is being carried out here? [1]
Page 8 of 97
Computer Science 2210
Topical Past Papers
(e) Give two different validation checks you would use for inputs to cells:
B2
B5
13 A company requests new customers who register online to give the following details:
• name
• address
• type of credit/debit card
• payment card number
All details must be entered.
(a) (i) Describe one suitable different validation check for each field.
name
address
type of credit/debit card
payment card number
Page 9 of 97
Computer Science 2210
Topical Past Papers
3 A hospital holds records of its patients in a database. Four of the fields are:
• date of visit (dd/mm/yyyy)
• patient’s height (m)
• 8-digit patient ID
• contact telephone number
The presence check is one possible type of validation check on the data. For each field,
giveanother validation check that can be performed. Give an example of data which would fail
yournamed validation check.
A different validation check needs to be given for each field.
Date of visit
Patient’s height
Patient ID
Contact telephone
number
Page 10 of 97
Computer Science 2210
Topical Past Papers
Oct/NOV 2004
9. Customers are identified by a 6 digit code. The first three digits are between 000 and 100
fororganisations and between 300 and 600 for individuals. It is important that the 6 digit
customer code is correctly entered to the system.
Describe how
(i) verification
(ii) validation
can help to ensure that as few errors as possible occur. [6]
May/June 2006
A small business has one shop. It specialises in taking portrait photographs for customers.
Details of customers are stored on paper.
It is decided to buy a stand-alone computer and use it to store customer records in a file.
8. Data that is entered into the file needs to be verified and validated.
(a) Explain what is meant by the terms
(i) verification;
(ii) validation. [2]
(b) Describe two methods that can be used for validating the date of the original
commission. [4]
May/June 2007
5. (a) Describe what is meant by verification of data. [2]
(b) Give an example of an application which would require the data input to be
verified andexplain why it would be necessary. [2]
Page 11 of 97
Computer Science 2210
Topical Past Papers
Page 12 of 97
Computer Science 2210
Topical Past Papers
Trace the flow chart using the numbers 2 and 3. Write down each of the values of N in the
orderthat they are printed out.
(a) 2 [1]
(b) 3 [2]
Page 13 of 97
Computer Science 2210
Topical Past Papers
Page 14 of 97
Computer Science 2210
Topical Past Papers
2 Describe, with examples, two types of test data which could be used to test a system. [4]
(a) Complete the following table showing the expected output from the flowchart for the three
sets of input data:
Page 15 of 97
Computer Science 2210
Topical Past Papers
Page 16 of 97
Computer Science 2210
Topical Past Papers
Page 17 of 97
Computer Science 2210
Topical Past Papers
(a)Complete the following table for the three sets of input data.
Page 18 of 97
Computer Science 2210
Topical Past Papers
Page 19 of 97
Computer Science 2210
Topical Past Papers
(a) Complete the table to show what outputs you would expect for the two inputs.
Page 20 of 97
Computer Science 2210
Topical Past Papers
Page 21 of 97
Computer Science 2210
Topical Past Papers
Page 22 of 97
Computer Science 2210
Topical Past Papers
Page 23 of 97
Computer Science 2210
Topical Past Papers
The flowchart below shows the log on procedure. Several boxes have been left blank.
Complete the flowchart using items from the list.
Page 24 of 97
Computer Science 2210
Topical Past Papers
Page 25 of 97
Computer Science 2210
Topical Past Papers
Page 26 of 97
Computer Science 2210
Topical Past Papers
Page 27 of 97
Computer Science 2210
Topical Past Papers
Page 28 of 97
Computer Science 2210
Topical Past Papers
Page 29 of 97
Computer Science 2210
Topical Past Papers
Page 30 of 97
Computer Science 2210
Topical Past Papers
Page 31 of 97
Computer Science 2210
Topical Past Papers
Page 32 of 97
Computer Science 2210
Topical Past Papers
Page 33 of 97
Computer Science 2210
Topical Past Papers
Page 34 of 97
Computer Science 2210
Topical Past Papers
Page 35 of 97
Computer Science 2210
Topical Past Papers
Page 36 of 97
Computer Science 2210
Topical Past Papers
Page 37 of 97
Computer Science 2210
Topical Past Papers
Page 38 of 97
Computer Science 2210
Topical Past Papers
Page 39 of 97
Computer Science 2210
Topical Past Papers
Page 40 of 97
Computer Science 2210
Topical Past Papers
Page 41 of 97
Computer Science 2210
Topical Past Papers
Page 42 of 97
Computer Science 2210
Topical Past Papers
Page 43 of 97
Computer Science 2210
Topical Past Papers
Page 44 of 97
Computer Science 2210
Topical Past Papers
Page 45 of 97
Computer Science 2210
Topical Past Papers
Page 46 of 97
Computer Science 2210
Topical Past Papers
Page 47 of 97
Computer Science 2210
Topical Past Papers
Page 48 of 97
Computer Science 2210
Topical Past Papers
Page 49 of 97
Computer Science 2210
Topical Past Papers
Page 50 of 97
Computer Science 2210
Topical Past Papers
Page 51 of 97
Computer Science 2210
Topical Past Papers
Page 52 of 97
Computer Science 2210
Topical Past Papers
Page 53 of 97
Computer Science 2210
Topical Past Papers
Page 54 of 97
Computer Science 2210
Topical Past Papers
Page 55 of 97
Computer Science 2210
Topical Past Papers
Page 56 of 97
Computer Science 2210
Topical Past Papers
Page 57 of 97
Computer Science 2210
Topical Past Papers
Page 58 of 97
Computer Science 2210
Topical Past Papers
Page 59 of 97
Computer Science 2210
Topical Past Papers
Page 60 of 97
Computer Science 2210
Topical Past Papers
Page 61 of 97
Computer Science 2210
Topical Past Papers
Page 62 of 97
Computer Science 2210
Topical Past Papers
13 A heating system is being controlled by sensors and a computer. The temperature must be
keptbetween 15°C and 25°C. If 30°C is exceeded a warning message is generated and the
systemshuts down.
A flowchart of the process is shown below. Some of the items are missing.
Complete the flowchart, using item number only, from the list of items given.
Page 63 of 97
Computer Science 2210
Topical Past Papers
Page 64 of 97
Computer Science 2210
Topical Past Papers
Page 65 of 97
Computer Science 2210
Topical Past Papers
Complete the trace table for the flowchart using the following data:
0, 3, 5, 6, -4, -1, 0, 0, -4, 10
Page 66 of 97
Computer Science 2210
Topical Past Papers
Page 67 of 97
Computer Science 2210
Topical Past Papers
Page 68 of 97
Computer Science 2210
Topical Past Papers
Page 69 of 97
Computer Science 2210
Topical Past Papers
Page 70 of 97
Computer Science 2210
Topical Past Papers
Page 71 of 97
Computer Science 2210
Topical Past Papers
Page 72 of 97
Computer Science 2210
Topical Past Papers
1 (b) Write an algorithm to complete Task 1, using either pseudocode, programming statements
or a flowchart. [5]
(c) Give three different data sets that could be used to check your validation rules for Task 1.
Explain why you chose each data set. [6]
(d) Explain how your program calculates the price for a consignment (part of Task 3). You may
Page 73 of 97
Computer Science 2210
Topical Past Papers
2 Read this section of program code that inputs 10 positive numbers and then outputs the smallest
number input.
1 Small = 1000
2 Counter = 0
3 REPEAT
4 INPUT Num
5 IF Num < Small THEN Small = Num
6 Counter = Counter + 1
7 UNTIL Counter = 10
8 PRINT Small
(i) Identify three changes you would need to make to find the largest number input instead
of the smallest number. [3]
(ii) Rewrite the program code with your changes. [3]
4 The flowchart below inputs the height of children who want to ride on a rollercoaster. Children
under 1.2 metres are rejected. The ride starts when eight children have been accepted.
Page 74 of 97
Computer Science 2210
Topical Past Papers
[4]
Page 75 of 97
Computer Science 2210
Topical Past Papers
1 (b) Write an algorithm to complete Task 2, using either pseudocode, programming statements
or a flowchart. You can assume that the weight and contents have already been checked and
Page 76 of 97
Computer Science 2210
Topical Past Papers
(c) (i) Give two different data values that could be used to check your validation rules for sand
in Task 1. Explain why you chose each value. [2]
(ii) Give two different data values that could be used to check your validation rules for
cement in Task 1. Explain why you chose each value. [2]
(d) Explain how your program calculates the price for an order (Task 3). You may include
programming statements as part of your explanation. [5]
2 Read this section of program code that inputs 10 positive numbers and then outputs the total.
1 Total = 0
2 Counter = 0
3 REPEAT
4 INPUT Num
5 Total = Total + Num
6 PRINT Total
7 Counter = Counter + 1
8 UNTIL Counter = 10
This code works, but it is inefficient.
(i) Suggest three improvements that could be made. [3]
(ii) Rewrite the program code with your improvements. [3]
3 The flowchart below calculates the number of tins of paint required to paint walls. The flowchart
inputs the height and width of a wall in metres, the number of doors and the number of windows.
A value of –1 for the height stops the input.
Page 77 of 97
Computer Science 2210
Topical Past Papers
[4]
Page 78 of 97
Computer Science 2210
Topical Past Papers
1 (a) All variables, constants and other identifiers should have meaningful names.
(i) When you performed the tasks, you used variables.
Write suitable declarations for two of these.
State what you used each one for. [4]
(ii) When you performed the tasks, you may have used constants.
Write suitable declarations for two of these.
State what you used each one for.
[4]
(b) Write an algorithm to complete Task 2, using either pseudocode, programming statements
or a flowchart. You should assume that the temperatures taken over the five hours are already
stored in an array. [5]
Page 79 of 97
Computer Science 2210
Topical Past Papers
2 Read this section of program code that should input 50 numbers and then output the average
of
the positive numbers only.
Page 80 of 97
Computer Science 2210
Topical Past Papers
[4]
Page 81 of 97
Computer Science 2210
Topical Past Papers
4 A routine checks the age and height of children who are allowed to enter a play area. The
children
must be less than 5 years of age and under 1 metre in height.
(a) The first set of test data used is age 3 and height 0.82 metres.
State what type of test data this is.
Give a reason for using this test data.
[2]
(b) Provide two additional sets of test data. For each, give
• the type of each set of test data
• the reason why it is used
Each type of test data and reason for use must be different.
[6]
5 A motor boat hire company decides to set up a database to keep information about boats that
are
available for hire. The database table, BOAT, will contain the following fields:
Boat Name; Model; Engine Power (in hp); Number of Seats; Life Raft (whether there is a life raft
kept on the boat); Day Price (price for a day’s hire).
(a) Give the data type you would choose for each field. [3]
Page 82 of 97
Computer Science 2210
Topical Past Papers
1 (a) All variables, constants and other identifiers should have meaningful names.
(i) For three of the variables that you have used in Task 1, state the name, type and its use. [3]
(ii) Name and describe the data structure(s) that you have used to store the donation totals
for each charity. Explain why you chose your data structure(s). [3]
Page 83 of 97
Computer Science 2210
Topical Past Papers
3 The flowchart below inputs an integer. The predefined function DIV gives the value of the
division,
for example Z ← 11 DIV 3 gives the value Z = 3. The predefined function MOD gives the value
of the remainder, for example Z ← 11 MOD 3 gives the value Z = 2.
Page 84 of 97
Computer Science 2210
Topical Past Papers
[4]
4 IF ... THEN ... ELSE ... ENDIF and CASE ... OF ... OTHERWISE ... ENDCASE
are two different conditional statements that you can use when writing pseudocode.
Explain, using examples, why you would choose to use each conditional statement. [6]
Page 85 of 97
Computer Science 2210
Topical Past Papers
1 (a) All variables, constants and other identifiers should have meaningful names.
For four of the variables, constants or arrays that you used in Task 1, state the name, data
structure, data type and its use. [8]
Page 86 of 97
Computer Science 2210
Topical Past Papers
(b) Decide, with reasons, whether the numbers 10 and 20 are within or outside the range.
[4]
3 The flowchart below inputs the price of an item under $10. The change from a $10 note is
output.
Any amount less than 5 cents is rounded up to 5 cents.
The predefined function INT rounds a number down to the nearest whole number; for example
Z ← INT(5.7) gives the value Z = 5
Page 87 of 97
Computer Science 2210
Topical Past Papers
Page 88 of 97
Computer Science 2210
Topical Past Papers
[5]
[3]
5 REPEAT ... UNTIL and WHILE ... DO ... ENDWHILE are two different loop
structures you can use when writing pseudocode.
Explain, using examples, why you would choose to use each type of loop. [6]
Page 89 of 97
Computer Science 2210
Topical Past Papers
1 (b) Give two different validation checks you could have used for data entry in Task 1. For each
check explain why it could be used and provide a set of data for testing. [6]
(c) Write an algorithm to complete Task 3, using either pseudocode, programming statements
or a flowchart. You may assume Task 2 has been completed. [5]
(d) Explain how your program finds out how many boats are available for hire (Task 2).
Any programming statements used must be fully explained. [4]
2 Write an algorithm using either pseudocode or a flowchart, to:
• input a positive integer
• use this value to set up how many other numbers are to be input
• input these numbers
• calculate and output the total and the average of these numbers. [6]
4 IF … THEN … ELSE … ENDIF is one type of conditional statement used when writing
pseudocode.
Identify and describe another type of conditional statement that you could use when writing
pseudocode. Give a reason why you would use this type of conditional statement. [4]
Page 90 of 97
Computer Science 2210
Topical Past Papers
[5]
Page 91 of 97
Computer Science 2210
Topical Past Papers
Page 92 of 97
Computer Science 2210
Topical Past Papers
2 This section of program code asks for 80 numbers between 100 and 1000 to be entered. It
checks that the numbers are in the correct range, and stores them in an array. It counts how
many of the numbers are larger than 500 and then outputs the result when the program is finished.
1 Count = 0
2 FOR Index = 1 TO 80
3 INPUT 'Enter a number between 100 and 1000', Number
4 WHILE Number = 99 AND Number = 1001
5 INPUT 'This is incorrect, please try again', Number
6 ENDWHILE
7 Num[80] = Number
8 IF Number > 500 THEN Count = Count + 1
9 UNTIL Index = 80
10 PRINT Index
11 PRINT ' numbers were larger than 500'
There are four lines of code that contain errors.
State the line number for each error and write the correct code for that line. [4]
3 (a) Explain the difference between a validation check and a verification check. [2]
(b) Describe, using an example, how data could be verified on data entry. [2]
(c) Explain what is meant by the term library routine. [2]
Page 93 of 97
Computer Science 2210
Topical Past Papers
1 (b) Explain how your program for Task 1 ensures that each 3-digit identity code is unique. [2]
(c) Write an algorithm for Task 2, using either pseudocode, programming statements or a
flowchart.
Assume that Task 1 has been completed. [5]
(d) (i) Explain how your program for Task 3 finds the cows with a daily yield of less than 12 litres of
milk for four days or more in the week. Any programming statements used in your answer must be
fully explained. [5]
Page 94 of 97
Computer Science 2210
Topical Past Papers
2 (a) Draw a flowchart for an algorithm to input numbers. Reject any numbers that are negative
and count how many numbers are positive. When the number zero is input, the process ends and
the count of positive numbers is output.
(b) Explain the changes you will make to your algorithm to also count the negative numbers. [2]
3 This pseudocode algorithm inputs two non-zero numbers and a sign, and then performs the
calculation shown by the sign. An input of zero for the first number terminates the process.
INPUT Number1, Number2, Sign
WHILE Number1 <> 0
IF Sign = '+' THEN Answer Number1 + Number2 ENDIF
IF Sign = '-' THEN Answer Number1 - Number2 ENDIF
IF Sign = '*' THEN Answer Number1 * Number2 ENDIF
IF Sign = '/' THEN Answer Number1 / Number2 ENDIF
IF Sign <> '/' AND Sign <> '*' AND Sign <> '-' AND Sign <> '+'
THEN Answer 0
ENDIF
IF Answer <> 0 THEN OUTPUT Answer ENDIF
INPUT Number1, Number2, Sign
ENDWHILE
(a) Complete the trace table for the input data:
5, 7, +, 6, 2, –, 4, 3, *, 7, 8, ?, 0, 0, /
[3]
(b) Show how you could improve the algorithm written in pseudocode by writing an alternative
type of conditional statement in pseudocode. [3]
4 A programmer has written a routine to store the name, email address and password of a
contributor to a website’s discussion group.
(a) The programmer has chosen to verify the name, email address and password.
Explain why verification was chosen and describe how the programmer would verify this data. [4]
(b) The programmer has also decided to validate the email address and the password.
Describe validation checks that could be used. [2]
5 A program checks that the weight of a basket of fruit is over 1.00 kilograms and under
1.10 kilograms. Weights are recorded to an accuracy of two decimal places and any weight not
in this form has already been rejected.
Page 95 of 97
Computer Science 2210
Topical Past Papers
(b) Explain how your program for Task 1 produces a unique estimate number. [2]
(c) Write an algorithm for part of Task 2 to check that the chosen processor and chosen RAM are
in stock, using either pseudocode, programming statements or a flowchart. Assume that Task 1
has been completed. Do not check the other components or produce the order. [5]
(d) Explain how your program completes Task 3. Any programming statements used in your
answer must be fully explained. [5]
Page 96 of 97
Computer Science 2210
Topical Past Papers
[5]
(b) Explain how you would change the algorithm to input eight digits (seven digits and the check
digit) and output if the check digit entered is correct or not. [3]
4 A programmer has written a routine to check that prices are below $10.00. These values are
used as test data.
10.00 9.99 ten
Explain why each value was chosen. [3]
Page 97 of 97