Computer Science HL P2 PDF
Computer Science HL P2 PDF
IB DIPLOMA PROGRAMME
PROGRAMME DU DIPLME DU BI
PROGRAMA DEL DIPLOMA DEL BI
N02/650/H(2)+
COMPUTER SCIENCE
HIGHER LEVEL
PAPER 2
Wednesday 20 November 2002 (morning)
2 hours 30 minutes
INSTRUCTIONS TO CANDIDATES
y
y
882-312
8 pages
2
1.
N02/650/H(2)+
A small shop stocks drinks and other items for sale. Details of the items are held in a stock
file with the following record structure:
newtype ITEM record
CODE integer
DESCRIPTION string
PRICE real
STOCK integer
REORDER integer
endrecord
declare DATA is ITEM file
Records are held in the DATA file in sequential order of CODE which is a 5-digit integer. The
following algorithm conducts an iterative binary search of the DATA file.
procedure BINARYSEARCH(val
val
ref
ref
//
//
//
//
WANTED integer,
SIZE integer,
FOUND boolean,
PLACE integer)
endprocedure BINARYSEARCH
882-312
N02/650/H(2)+
(Question 1 continued)
(a)
[2 marks]
(b)
[2 marks]
(c)
[2 marks]
(d)
[10 marks]
Outline a Boolean condition that could be used to ensure that the CODE
numbers all have 5 digits.
[2 marks]
(e)
(f)
The algorithm must also output the total value of the stock in the shop
(that is the sum of STOCK*PRICE for every item).
[7 marks]
882-312
Turn over
N02/650/H(2)+
(Question 1 continued)
The sales figures for each month are held in a 2D integer array SALES[500,13] with the
following structure:
1
10
11
12
13
10343
22
10356
53
43
10412
11342
12
...
etc.
...
...
...
13
15
32
34
34
33
...
...
...
...
...
...
...
...
...
...
500
(all cells are filled with integer data)
The first column of the array contains the 5-digit ITEM number and the remaining columns contain
the sales figures with column 2 being January sales, column 3 being February sales and so on.
(g)
882-312
[5 marks]
N02/650/H(2)+
(a)
State one reason why the CT numbers are stored in 2 bytes even though
only 12 bits are required for storage.
[2 marks]
Outline one difference and one similarity between parity checks and check
sums used to ensure data integrity.
[4 marks]
(c)
[2 marks]
(d)
[8 marks]
(e)
[4 marks]
(f)
Outline any two precautions that a researcher should take to ensure that
his or her username and password are not found out by hackers.
[4 marks]
Explain one way in which the job of a researcher in this field might have
changed since the introduction of CT.
[2 marks]
[4 marks]
(b)
(g)
(h)
882-312
Turn over
6
3.
N02/650/H(2)+
Consider the following two algorithms used to delete an integer value from an array:
function SHUFFLE(var PLACE integer,
ref INTARRAY integer array[1..SIZE]) result boolean
if PLACE <= SIZE then
for I <-- PLACE to (SIZE 1) do
INTARRAY[I] <-- INTARRAY[I+1]
endfor
return true
else
return false
endif
end SHUFFLE
function MARK (var PLACE integer,
ref INTARRAY integer array[1..SIZE]) result boolean
if PLACE <= SIZE then
INTARRAY[PLACE] <-- 999
return true
else
return false
endif
end MARK
(a)
[6 marks]
A queue is implemented as a linked list, g is the element at the front of the queue:
a
rear
front
(b)
[3 marks]
(c)
Explain how this structure can be modified to use a circular linked list.
[2 marks]
(d)
Outline a method that could be used to count the number of items in the
modified queue.
[4 marks]
882-312
7
4.
N02/650/H(2)+
During the execution of a computer program, data held in primary memory is passed to the
ALU and instructions are passed to the CU.
(a)
(b)
[6 marks]
[2 marks]
As part of the fetch-decode-execute cycle, the interrupt register is checked. An 8-bit register
is shown below:
7
(d)
(e)
[1 mark]
[2 marks]
Buffers are used with peripheral devices. In some situations they may
become full.
[2 marks]
882-312
(i)
(ii)
Outline one way that the system would deal with a full buffer.
[2 marks]
Turn over
8
5.
N02/650/H(2)+
A data processing company uses a mainframe computer to prepare mobile phone bills. When
a new customer is added the data is put onto a tape file. This tape is then sorted by customer ID
order and used to update the customer master file which is held on disk, also in customer ID order.
(a)
(b)
State one error that can occur when the master file is updated (not including
file corruption or programming errors).
Outline one reason why the master file is held on disk.
[1 mark]
[2 marks]
882-312
Outline two problems that may occur when combining the two companies
customer files.
[4 marks]
[8 marks]