You are on page 1of 21

ZI

MBABWESCHOOLEXAMI
NATI
ONSCOUNCI
L
Gener
alCer
ti
fi
cat
eofEducat
ionAdv
ancedLev
el

COMPUTERSCI
ENCE 6023/
2
PAPER2Pr
act
ical
NOVEMBER2020SESSI
ON 3hour
s
Addi
ti
onalmateri
als:
CDforeachcandidat
e
Pr
int
ingf
aci
li
ty
TI
ME3hour s
I
NFORMATI
ONFORCANDI
DATES
Thi
sisapur
elypr
act
ical
exami
nat
ion.Al
lanswer
sshoul
dbepr
int
ed.Handwr
it
tenanswer
s
Wi
l
lnotbemar
ked.
Thi
spaperconsi
stsoft
hreesect
ions.
Sect
ionA 20mar
ks
Sect
ionB 50mar
ks
Sect
ionC 30mar
ks
Answeronequest
ionf
rom eachsect
ion.
Eachanswersheetshoul
dincl
udet
hef
oll
owi
ngi
nfor
mat
ioni
ntheheadersect
ion:
 Candi
dat
eNameandCandi
dat
eNumber
 Cent
reNameandDat
e
 Subj
ectCode

Whenanswer
ingpr
ogr
ammi
ngquest
ions,
indi
cat
ethel
anguageused.
All
workshouldbebackedupbyasof tcopyonaCD.
Ifacandi
datepri
ntsonmor ethanonesheet,
fast
entogetherwi
thstr
ing.
All
answersshouldbecorr
ectl
yandclearl
ynumbered.
___
___
____
______
_____
____
_____
_ _
___
_____
____
_____
____
____
_ __
___
___
______
___
___
Thi
sspeci
menpaperconsi
stsof8pr
int
edpages
Copy
right
:Zi
mbabweSchool
Exami
nat
ionsCounci
l
,N2020.
©ZI
MSECN2020 [
Tur
nov
er
Sect
ionA[20marks]
Answeronequest
ionfr
om thi
ssect
ion.

1.Useaspreadsheetofyourchoi
cetosimul
atet
hef
oll
owi
ngl
ogi
coft
hewor
ksheet
(
a)Useonlythefol
lowi
ngformulae:

Si
mul
atet
heci
rcui
tbel
owont
hespr
eadsheetandcompl
etet
het
rut
htabl
e

Cov
ertt
o1sand0s
A B C B’
=a A.
B=b B’
+C=c (
A.B)’
=d (
A.B)
’.
B’.
C=c.
d
0 0 0 1 0 1 1 1
0 0 1 1 0 1 1 1
0 1 0 0 0 0 1 0
0 1 1 0 0 1 1 1
1 0 0 1 0 1 1 1
1 0 1 1 0 1 1 1
1 1 0 0 1 0 0 0
1 1 1 0 1 1 0 0

(
b)DrawtheVonNeumannandHarvar
darchi
tect
ureexpl
aini
ngt
hei
rdi
ff
erences.Just
if
yyour
answertowhi
char
chi
tect
urei
sthebesttoadopt
[7]
Poi
ntof
VonNeumannAr
chi
tect
ure Har
var
dAr
chi
tect
ure
Compar
ison

Di
agr
am
TheHar vardarchi tectur
ei samoder n
comput erarchitecturebasedont he
TheVonNeumannar chi
tecture
Har vardMar kIr elay-basedcomput er
i
sat heor et
icaldesignbasedon
model whichst oredi nstr
uct i
onson
thest ored-program comput er
punchedt ape(24bi tswide)anddat ai
n
concept .Theconceptwas
electro-
mechani cal counters.Some
Descr
ipt
ion designedbyamat hemat i
cian
exampl esofHar v ardarchitectures
JohnVonNeumanni n1945and
i
nv olveear l
ycomput ersystemswher e
currentlyser vesast he
progr ammi nginputcoul dbei none
foundat ionofal mostal l
medi a,forexampl e,punchcar ds,and
moder ncomput er
s.
storeddat acoul dbei nanot hermedia,
forexampl e,ont ap..

InVon-Neumannar chi
tectur
e, InHarvardarchi
tect
ure,t
heCPUi s
thereisnoseparatedat aand connectedwithboththedatamemor y
program memor y.Inst
ead, a (RAM)andpr ogram memor y(ROM),
singl
ememor yconnectionis separat
ely.
Ar
rangement giventotheCPU. Hassepar at
ememor yspacef or
Hasonl yonebust hatisused i
nstruct
ionsanddatawhi chphysi
cal
ly
forbothinst
ructi
onsf etches separat
essignalsandstoragecodeand
anddat atr
ansfers. datamemor y.

Incontrasttot heHarv
ard
I
trequir
esmorehardwaresi
ncei
twil
lbe
Har
dware archi
tecture,thisr
equi
resless
r
equiri
ngsepar
atedataandaddr
essbus
r
equi
rement
s hardwaresi nceonlyacommon
f
oreachmemor y.
memor yneedst obereached.
Space Von-NeumannArchi
tect
ure
Thi
srequi
resmor
espace.
requi
rement
sr equi
resl
essspace.

Thespeedofexecut i
onisfast erbecause
theprocessorf etchesdataand
Speedofexecutionissl
ower i
nstructi
onssi mul t
aneously.Apr ogram
Speedof si
nceitcannotfetchthedat
a runni
ngonHar v ardarchi
tecturecanbe
execut
ion andinst
ruct
ionsatthesame executedfasterandmor eefficientl
y
ti
me. becausethei nstructi
onsanddat aare
handledmor equi cklyastheydonot
havetoshar ethesamebus

Spaceisnotwastedbecause Itr
esult
sinwastageofspacesi
nceift
he
thespaceofthedatamemor y spaceislef
tint
hedatamemor ythent
he
Spaceusage canbeut i
li
zedbythe i
nst r
uct
ionsmemorycannotusethe
i
nst r
uct
ionsmemor yandvi
ce- spaceofthedatamemor yandvi
ce-
versa. versa.

Theprocessi
ngunitwould Theprocessinguni
tcancomplet
ean
I
nstr
ucti
on
requi
retwoclockcycl
esto i
nstr
uctioni
nonecy cl
eifappr
opri
ate
Pr
ocessi
ng
complet
eaninstructi
on. pi
pel
iningplanshavebeenset
Inst
ruct
ionsanddatausethe
Cost Compl
exki
ndofar
chi
tect
urebecausei
t
samebussy stem t
her
efor
ethe
desi
gnanddev elopmentof employstwobusesfori
nstruct
ionand
contr
oluni
tissimplif
ied,
hence data,af
actort
hatmakesdev el
opmentof
thecostofproducti
onbecomes thecont
roluni
tcomparat
ivelymore
mini
mum expensi
ve.

VonNeumannar chit
ectur
eis Harvardar chitectur
eisanewconcept
usual
lyusedl i
ter
all
yinall usedspeci fi
cal l
yinmicrocont
rol
ler
sand
machinesf r
om desktop di
gitalsignal processi
ng(DSP)..Harv
ard
Use
comput er
s,notebooks,hi
gh archi
tecturei swidelyusedonembedded
perf
ormancecomput er
sto comput ersy stemssuchasmobi l
e
workstati
ons. phones, burglaralarmsetc.

c)Someoft
( hecomponent
sofacomput ersy
stem ar
e:
Peri
pheral
s keyboard
Monitor
I
/OPor t
s VDUcont r
oll
er
KeyboardControll
er
Memor y MainMemor y
SecondaryStorage
Syst
em buses Databus
Addressbus

Dr
awt
hedi
agr
am bel
owandl
abel
thecomponent
susi
ngt
hel
i
stabov
e
2.(a)Aretai
lst
oreinMutarewant
stobuyanaccounti
ngapplicati
onpackagewhi
chwill
assi
stincarr
yingoutdail
yst
oreoper
ati
ons.Theoperat
ionsincl
udetacki
ngpr
oductstock,
captur
ingsol
dpr oduct
sandpri
nti
ngrepor
tsformanageri
alstaf
f

Asasy st
em dev
eloper
,desi
gnasuit
abl
esof
twar
ear
chi
tect
uref
orment
ioned
requi
rement
susinganappropr
iat
edesi
gn

(
b)Apowerst
ati
onhasasaf
etysy
stem basedont
hreei
nput
stoal
ogi
cnet
wor
k.Awar
ningsi
gnal
(S
=1)i
spr
oducedwhencer
tai
ncondi
ti
onsoccurbasedont
hese3i
nput
sdescr
ibedi
nthet
abl
ebel
ow:
Bookl
et3q10p38

Awar ni
ngsignal
(S=1)will
begener
atedif
:
o
ei
ther(a)Temperat
ure>120CandCool i
ngWater100l/hr
o
or ( b)Temperat
ure120Cand(Pressure>10barorCooli er100l
ngWat /hr
)

Drawalogicnet
workandtr
utht
abl
etoshowal
lthepossi
blesi
tuat
ionswhent
hewar
ningsi
gnal
coul
dberecei
ved.
Stat
ement:S=1if(T=1ANDW =NOT1)OR(T=NOT1AND(P=1ORW =NOT1) )

Expr
essi
on:T•
W’+T
P W T W’ P+W’ W’.
T T’ (
P+W’
).
T’ (
(P+W’
).
T’)
+(W’.
T)
0 0 0 1 1 0 1 1 1
0 0 1 1 1 1 0 0 1
0 1 0 0 0 0 1 0 0
0 1 1 0 0 0 0 0 0
1 0 0 1 1 0 1 1 1
1 0 1 1 1 1 0 0 1
1 1 0 0 1 0 1 1 1
1 1 1 0 1 0 0 0 0
Secti
onB[50mar ks]
Answeronequest i
onfrom thi
ssect
ion.
3.(a)Writ
eanalgor
it
hm inpseudocodet ocal
cul
atetheaver
ageofasetof5mar
ksf
ort
en
student
senter
edthroughthekeyboard.
[
8]

Start
Total/Sum=0
Average=0
Forcount Student I=1to10
Ent erStuent Name
Forcount Mar k=1t o5
I
nput/ Enter/Readmark
Total
=Tot al+mark(Total
+=mark)
Nex tcount Mar k
Aver age=total/count Mark
Display /Pri
ntSt undentNameandAv er
age
Nex tCount Student
End/St op

(b)Designani nt
erf
aceandwrit
eapr ogr
am toconvertacrest
ohectares.[1acr
e=0, 404686
hectares.
]
Thepr ogram shoul
daccepti
nputfr
om useranddisplaytheoutput
.Theprogram shouldworkf
or
therealnumber saswellaswhol
enumber s(e.
g.itshouldaccept7,
.2acres,0.
5acresetc.
)
[8]
1bvisualbasi
c2012used

Desi
gn

l
blNoOf
Acr
es

t
xtacr
es

bt
nCal
cul
ate

Code

Publ
i
cCl
assFor
m1

Pr
ivateSubbt nCalculate_Cli
ck(
senderAsObj
ect
,eAsEv
ent
Args)Handl
esbt
nCal
cul
ate.
Cli
ck
'declari
ngv ari
ables'
Di m acreAsSi ngle
Di m hectareAsSi ngl
e
Consthet=0. 404686
'assinngv ar i
able'
acr e=txtacr es.Text
'formulathatwi ll
wor k'
hect ar
e=acr e*het
'showi
ngtheout
puti
namassagebox'
MsgBox("
thenumberofhect
aresar
e”,
“Quest
ion3a"&hect
are)
EndSub
EndClass

Resul
ts

(c)Byusingthebubbl
esortal
gor
it
hm,
wri
teacodet
osor
tani
ntegerar
rayof10(
ten)
element
si nascendi
ngor
der.
[
25]
I
tworksasfol
lows,
1.Comparethef i
rsti
tem inthel
istwi
tht hesecond.
2.I
ftheyareinthewr ongorder,
swapt hem ar ound.
3.Comparethesecondi tem tot
hethi
rdi tem.
4.I
ftheyareinthewr ongorder,
swapt hem ar ound.
5.Conti
nuedoingt hi
suntilt
heendofthear ray .
6.I
fyouhav ehadt oswapanyi t
ems,repeatt heprocessunt
ilnoswapsar
emade.

ForCount1=1To10
ForCount2=1To10
I
fA[Count2]>A[Count
2+1]Then
TempA[ Count2]
A[Count2]A[
Count2+1]
A[Count2+1]Temp
EndI
f
NextCount2
NextCount1
(d)Usingapr ograminglanguageofy ourchoi
ce,wri
teaprogr
am thatacceptdi
stanceofa
j
our ney(i
nkm)andt i
me( inhours)tobespendduringthej
ourney
.
Thepr ogr
am t hencalcul
atesthespeed;anddetermineswhet
herthespeedisslow,normalor
high.Theprogr am t
hendisplaysthespeedcategoryinwhi
chthespeedbelongsto.
Thespeedcat egor
iesareasf ol
lows
Slow 1–45km/ h
Normal 1–45km/ h
High 1–45km/ h [9]
3d design

Code

Publ
i
cCl
assFor
m1

Pr
ivateSubbt ncalculate_Click(
senderAsObj
ect
,eAsEv
ent
Args)Handl
esbt
ncal
cul
ate.
Cli
ck
'
decl aringv ariabl
es'
Dim di stanceAsSi ngl e
Dim speedAsSi ngle
Dimt imetakenAsI nteger
'
assi gningv ariables'
distance=t xtdistance.Text
ti
met aken=t xtti
me. Text
speed=di stance/t i
met aken
SelectCasespeed
Case1To45
'
out putti
ngt her esults'
MsgBox("
yourspeedi
nkm/hri
s"&speed&"cat
egorysl
ow")
Case45To80
'
output
ti
ngtheresul
ts'
MsgBox("
yourspeedinkm/
hri
s"&speed&"categor
yNormal"
)
CaseIs>80
'
output
ti
ngtheresul
ts'
MsgBox("
yourspeedinkm/
hri
s"&speed&"categoryHi
gh"
)
EndSelect

EndSub
EndClass
4. (
a)Ticketsaresoldforaconcer tat$30eachandapersoni
snotall
owedmor ethan50
ti
ckets.
Thedet ai
lsfort
hediscountsar egi
veninthetabl
ebel
ow
Numberoft icket
s di scount
10-20 10%
21-50 20%
Drawaf l
owchartofaprogram thataccept
sthenumberoft
icket
s,cal
cul
atesdiscount
anddisplays
thetotalcostoftheti
cket
s. [12]

START
READTi cketsBought
ti
cketsCost=$30‘ constant
IFTicketsBought>50THEN
OUTPUT“I nvali
d,Pleaser e-ent
erti
cketsbought
ELSE
OUTPUT Tot al
Cost=Ti cketCost*Ticket
sBought
ENDI F
IFTicketsBought>=10ANDTi cket
sBought<20THEN
Discount=Tot alCost* 0.
1
ELSEI FTicketsBought>=20ANDTi cket
sBought<=50THEN
Discount=Tot alCost* 0.
2
ELSE
Discount=Tot alCost* 0
ENDI F
Payment=Tot al
Cost–Di scount
OUPUTPay ment
STOP

REPEAT
PRI
NT"Howmanyticket
swoul
dyoul
iketobuy
?"
I
NPUTNumberOfTi
ckets
UNTILNumber
OfTi
cket
s>0ANDNumber Of
Ticket
s<51

I
FNumber
OfTi
cket
s>=10ANDNumber
OfTi
cket
s<21THEN
Di
scount← 0.1
ELSEIFNumberOfTickets>=10andNumberOfTi
cket
s<51THEN
Di
scount← 0.2
ELSE
Di
scount← 0
ENDIF
Cost← Number OfTi
ckets*30*(1–Discount
)
PRINT"Yourt
icketscost"
,Cost

OR
REPEAT
PRI
NT"Howmanyticket
swoul
dyoul
iketobuy
?"
I
NPUTNumberOfTi
ckets
UNTILNumber
OfTi
cket
s>0ANDNumber Of
Ticket
s<51

I
FNumber OfTicket
s<10THEN
Discount← 0
ELSEI
FNumber OfTicket
s>=10ANDNumberOfTi
cket
s<21THEN
Discount← 0.1
ELSE(IFNumber OfTicket
s>=10andNumber
OfTi
ckets<51THEN)
Discount← 0.2

ENDIF
Cost← Number Of
Ticket
s*30*( 1–Di
scount
)
PRINT"Yourt
icket
scost",Cost
(b)Apr ogram acceptstotalamountofdai lysal
esforeachtr
ansact
ionsandthegrandtot
alsales
for
eachsalesper sonandt hetotalofall
thesales.Theprogr
am t
henoutputssal
esperson
number ,total
sal
espersal espersonandgr andtotal.
(
i)Drawast ructurediagram toil
l
ustratestheprogram, [13]
(
ii
)Wr
it
eapr
ogr
am f
ort
hescenar
iodescr
ibed. [
25]
Secti
onC[ 30mar ks]
Answeronequest ionfrom t hi
ssecti
on.
5.(
a)Aschool hasapolicythataleanerhastopar ti
cipateinasleastoneclub.Eachcl
ubhasat
l
eastone
pat
ronwhoi sateacher.Ateachermayonl ypatrononecl ub.
(i)DrawanER- di
agram from t
hissystem wit
hclearl abel
sont herel
ati
onshipsamongstthe
enti
ti
esinthescenario,i
nsecondnor malform( 2NF). [6]

nam Club

D
name e name

I
ner
ear
l I
D
addr

SCHOOL LEARNER l
i
nk CLUB
s
es

school
I
D

number
pol
i
cy addr
es

E.
C
s
TEACHER

ad
dr Name
e
s s

6.
(
ii
)Suggestatt
ri
but
esf oreachent i
tybydr awi
ngonthesamediagram orbyt
ypi
ngi
na
separat
e
tabl
efrom t
hedatabasemodel
Stat
ethepri
marykeyf oreachentity.
[9]
Enti
ty Attr
ibutes Primarykey
School SchoolID,AddressName, Pol
icy schoolI
D
Learner LearnerID,Address,Name l
earnerID
Club ClubID,Name ClubID
Teacher ECNumber ,Address,Name ECnumber

(
b)Ashopkeeperusesasi
ngl
efi
l
etor
ecor
ddet
ail
sofsal
esofgoods
Writ
einthecorr
espondi
ngspacebel
ow,
thecor
rectnamef
oreachofA,
B,CandDf
rom t
he
f
igureaboveusi
ngonlyt
hefoll
owi
ng:
 Processor
 AddressBus
 DataBus
 MainMemor y
 Keyboard
 Vi
sual Di
splayUni
t

Answer
:

A=Vi
sual
displ
ayuni
t

B=Pr
ocessor

C=Mai
nmemor
y

D=Key
boar
d

(
b)Showthest
agesofaqui cksor ttoputt
hef
oll
owi
ngnumber
sint
oascendi
ngnumer
ical
order
:
24 8 371115( OCR 2509Januar
y2005q4)

•hi
ghli
ghtf ir
stnumberi nthel i
st(the‘searchnumber’
)
•poi
nterateachendofl ist
•Repeat:
Compar enumber sbei ngpoi nt
edt o…
…ifinwr ongor der,swap
Mov epoi nterofnon- searchnumber
Unt i
lpointerscoincidesosear chnumberi ncorr
ectposi
ti
on
Splitl
istinto2subl ists
Quicksor teachsubl i
st
•Repeatunt i
lallsubli
stshav easinglenumber
•Putsublistsbackt ogether

QuickSor t
Fir
stt hedataisplacedinarowwi t
hanar rowunderthefir
standlastval
ues,
poi
nti
ngateach
ot
her,onei sf
ixedwher easoneismov able.
Ift
het wovaluesareinthecorr
ectorderthenmovethemov abl
earrowtowar
dst
hef i
xed
ar
row,elseswapt hei
temsandt hearr
ows.
Continuetor epeatthi
sunti
lthearr
owscol li
de.
Continuetor epeatthi
sprocessunti
lthefil
esareofalengthofone.
Spli
tint
osubl i
sts,repeat…
OR
alt
ernat
iveanswerusi ngapivot:
Selectani tem atrandom, thepi
vot
Createtwonewl i
sts:
…onewi thalli
temsl essthanpivot,
…otherwi thitemsgr eaterthanpiv
ot
Repeat
…unt il
listsonlyhav eonei t
em
(demonstratethisonnumber sgiven)

Qui
cksort
:
Usest
wopoi
nter
s
Compar
enumber
satpoi
nter
s&swapi
finwr
ongor
der
Mov
eonepoi
nteratat
ime
Al
ter
nat
ivemet
hodusesapi
vot
Repeat
edspl
i
tti
ngi
ntosubl
i
sts
Subl i
stsareindependentsocanbesortedsepar
atelyusingarecur
siv
e
algori
thm
Subl i
stsarer educedtoasingl
enumberthenputtogethertof
orm sor
ted
l
ist.
Adv antage:
Ver yquickforl ar
gesetsofdat
a.
Disadvantage:
Initi
alarrangement

You might also like