A1 CS Notes by MAK
A1 CS Notes by MAK
PAGE 1
!"#$%&'()(
!"#$%&'()(*%#
*+(
,#-(
PAGE 2
Cambridge International AS & A Level Computer Science 9618 syllabus for 2021, 2022 and 2023. Subject content
AS Content
Computational thinking is developed using a structured approach that includes the use of programming and
problem solving skills to provide solutions to real life problems. It requires the manipulation and storage of
different types of data and the communication of solutions over networks.
1 Information representation
What is a nibble?
A group of 4 bits are referred to as a nibble.
What is a byte?
In the world of computers and microcontrollers, 8 bits are considered to be a standard group. It
is called a byte. Microcontrollers are normally byte oriented and data and instructions normally
use bytes. A Byte can be broken down into two nibbles.
!"##$%$&'$()$*+$$&(,&"*-(
MUHAMMAD ALI KHAN
PAGE 5
!"#$%&%'()&*)+*,(-(*./*,($)**0*1!"#"$%&'()*+&,-./&)00&12&34(&3"'(5&6!"01$%&
'()*+&6,---%&'784&12&34(&3"'(9I&34(:(&"+&34(&;13(*3")0&21:&
81*27+"1*&<4(*&=17&>(3&31&34(&"*3(:+(83"1*&12&+31:)>(?*(3<1:!"*>?
)*@&')"*&'('1:=9&<4(*&6!"01$%&"+&+1'(3"'(+&'()*3&31&'()*&6,-./%&
)*@&34"+&"+&0):>(0=&@7(&31&4"+31:"8)0&0)*>7)>(&7+)>(5&ABC&"+&3=;"8)00=&
@(+8:"#(@&<"34&34(&#"*):=&7+)>(D&)&6!"01#=3(&12&ABC%&"+&,-./&E9I&)&
!"01#=3(&12&FG&"+&3=;"8)00=&,---&E9I&+1'(&H'1+3IJ&KLM+&7+(&34(&
#"*):=&7+)>(+&<4(*&34(=&:(2(:&31&34"*>+&0"!(&2"0(&+"N(+&)*@&2:((&+;)8(5
F"+31:"8)00=9&34(&81';73(:&+8"(*3"+3+"0@"*>&4):@<):(&)*@&'('1:=&
217*@&"3&()+"(+3&)*@&'1+3&81*O(*"(*3&31&817*3&34"*>+&"*&#"*):=&+"*8(&
34(=&<(:(&)837)00=&7+"*>&#"*):=&)3&)&01<&0(O(05&L"*8(&&.,-&&P,-./&"+&
;:(33=&801+(&31&&,-Q&9&34(&210!+&8:()3"*>&34(&4):@<):(?'('1:=&
)@@:(++"*>&)@1;3(@&34(&6!"01$%&;:(2"R&31&'()*&,-./&#=3(+&)*@&
6'(>)%&31&#(&&..-&&P,9-/S9TUV&"+&+3"00&;:(33=&801+(&31&&,-V&5
MUHAMMAD ALI KHAN
PAGE 6
uses between 8 and 32 bits per character, so it can represent characters from
languages from all around the world. It is commonly used across the internet. As it is
larger than ASCII, it might take up more space when saving documents.
Global companies, like Facebook and Google, would not use the ASCII character set
because their users communicate in many different languages.
MUHAMMAD ALI KHAN
PAGE 8
!"#$%&'()*+*',+-".$/'0!(,12'
3).+'#4.5+%6'$%+'#)7'8%)8+%'#4.5+%6'5+-$46+'79+&'*)#:7'5+9$;+'/"<+'#4.5+%6='>'5$%-)*+'
?)%'-9)-)/$7+'/))<6'/"<+'$'#4.5+%@'$#*'$'5$%-)*+'?)%'68)#A+'-$<+'/))<'/"<+'$'#4.5+%@'547'"?'
79+'5$%-)*+6'$%+'$**+*'7)A+79+%'79+'%+64/7'"6'#)7'79+'5$%-)*+'?)%'-9)-)/$7+'-$<+='B9+'
$%"79.+7"-'*)+6'#)7'A";+'$'6+#6"5/+'$#6C+%='
D$/4+6'/"<+'79"6'79$7'/))<'/"<+'#4.5+%6'547'*)'#)7'5+9$;+'/"<+'79+.'$%+')?7+#'67)%+*'"#'5"#$%&'
-)*+*'*+-".$/'0!(,1='E$-9'*"A"7'"6'6".8/&'-9$#A+*'"#7)'$'?)4%'5"7'5"#$%&'#4.5+%'C9"-9'$%+'
79+#'8/$-+*'$?7+%')#+'$#)79+%'"#')%*+%='
+=A='FGHIJK'"#'!(,
>#6C+%2'F'L'JJMM'G'L'MJJM
H'L'MJJJ'I'L'JMMJ
J'L'JJJJ'K'L'JJMJ
3)'FGHIJK'L'JJMMMJJMMJJJJMMJJJJJJJMJ'0"#'!(,1
N)7+2'>//'79+'O+%)6'$%+'+66+#7"$/')79+%C"6+'&)4'-$#:7'%+$*'"7'5$-<=
>88/"-$7")#'
B9+'!PQ3'"#'.$#&'8+%6)#$/'-).847+%6'67)%+6'79+'*$7+'$#*'7".+'"#'!(,'5+-$46+'79+'R(IHMH'
%+$/S7".+'-/)-<'-9"8'46+*'"#'79+')%"A"#$/'P!R'T('>B'.)79+%5)$%*'8%);"*+*'79+'7".+'+#-)*+*'
"#'!(,='B9"6'?)%.'"6'+$6"/&'-)#;+%7+*'"#7)'>3(PP'?)%'*"68/$&='
B9+'>7$%"'HS5"7'?$."/&')?'-).847+%6'46+*'!(,'7)'".8/+.+#7'?/)$7"#AS8)"#7'$/A)%"79.6='B9+'
RQ3'IUJK'8%)-+66)%'46+*'9$6'$'!(,'.)*+'79$7'$??+-76'79+'$**"7")#'$#*'6457%$-7")#'
"#67%4-7")#6='E$%/&'.)*+/6')?'79+'T/$&37$7")#'F'67)%+'79+'*$7+'$#*'7".+'"#'!(,='B9"6'/+*'7)'$'
C)%/*C"*+')47$A+')?'79+'-)#6)/+')#'M'R$%-9'KJMJ='B9+'/$67'7C)'*"A"76')?'79+'&+$%'67)%+*'$6'
!(,'C+%+'."6"#7+%8%+7+*'$6'MI'-$46"#A'$#'+%%)%'"#'79+'4#"7V6'*$7+@'%+#*+%"#A'.)67'?4#-7")#6'
"#)8+%$5/+='B9"6'9$6'5++#'%+?+%%+*'7)'$6'79+'W+$%'KJMJ'T%)5/+.='
!"#$%&'()*+*',+-".$/'0!(,1'!"#$
%&'()*+'!"#$'$,!)'#$!*-,.'#*/*('*+'0$10$+$&($#'23','452*('2*&,03'&6-2$07'
89:'*+',';,3'("'$<10$++'$,!)'"='()$'#$!*-,.'#*/*(+';*()','2*&,03'!"#$7'%&'
()$'89:>';*()'="60'2*(+';$'!,&'0$10$+$&('+*<($$&'&6-2$0+'?@@@@'("'
AAAAB7'86('*&'89:'!"#$'"&.3'=*0+('($&'"='()$+$',0$'6+$#'?@@@@'("'A@@AB7'
C)$'0$-,*&*&/'+*<'!"#$'!"-2*&,(*"&+'*7$7'A@A@'("'AAAA',0$'*&D,.*#'*&'89:7
PAGE 9
!"#$%&'()(*(
!"#$%&'&()*+'#*+',("-.%&&!(*'
+,(-#.
PAGE 16
Cambridge International AS & A Level Computer Science 9618 syllabus for 2021, 2022 and 2023.
1.2 Multimedia
Graphics
Candidates should be able to: Notes and guidance
Show understanding of how data for a bitmapped Use and understand the terms: pixel, file header,
image are encoded image resolution, screen resolution, colour depth, bit
depth
Perform calculations to estimate the file size for a
bitmap image
Show understanding of the effects of changing Use the terms: image resolution, colour depth
elements of a bitmap image on the image quality and
file size
Show understanding of how data for a vector graphic Use the terms: drawing object, property, drawing list
are encoded
Justify the use of a bitmap image or a vector graphic
for a given task
Sound
Candidates should be able to: Notes and guidance
Show understanding of how sound is represented and Use the terms: sampling, sampling rate, sampling
encoded resolution, analogue and digital data
Show understanding of the impact of changing the Impact on file size and accuracy
sampling rate and resolution
1.3 Compression
Candidates should be able to: Notes and guidance
Show understanding of the need for and examples of
the use of compression
Show understanding of lossy and lossless compression
and justify the use of a method in a given situation
Show understanding of how a text file, bitmap image, Including the use of run-length encoding (RLE)
vector graphic and sound file can be compressed
MUHAMMAD ALI KHAN
PAGE 18
!"#$%&'(!)"#*'#+,'-%.)/0
Graphic images that have been processed by a computer can usually be divided into two
distinct categories. Such images are either bitmap files or vector graphics. This section will
cover the two main image types: vector and bitmap, along with some compression techniques.
Bitmaps images are exactly what their name says they are: a collection of bits that form an
image. The image consists of a matrix of individual dots (or pixels) that all have their own color
(described using bits, the smallest possible units of information for a computer).
Let’s take a look at a typical bitmap image to demonstrate the principle:
Pixel
The smallest possible addressable area defined by a solid color, represented as binary, in an
31TU! U31T
image
Resolution
Image Resolution - how many pixels does an image contains per inch/cm? The more pixels
31TU U31T
used to produce an image the more detailed that image can be i.e. the higher its resolution. For
MUHAMMAD ALI KHAN
PAGE 19
instance a 10 Megapixel digital camera makes use of over 10 million pixels per image thus
offering a very high photographic quality.
Screen Resolution - The screen resolution tells you how many pixels your screen can display
31TU U31T
horizontally and vertically. It's written in the form 1024 x 768. In this example, the screen can
show 1,024 pixels horizontally, and 768 vertically:
Color depth - The number of bits used to represent the color of a single pixel
U031T 31T31T 0T
Many file types can be identified by using what’s known as a file header. A file header is a
‘signature’ placed at the beginning of a file, so the operating system and other software know
what to do with the following contents.
Many electronic discovery applications (computer programs) will use the file header as a means
to verify file types. The common fear is if a user changes a files extension or the file wasn’t
named using an applications default naming convention, that file will lose its association with the
program that created it.
For example, if you create a Microsoft Word document and name it ‘myfile.001’, instead of
‘myfile.doc’ and then attempt to locate all Microsoft Word files at a later date, you would miss
the file if you were looking for all files ending in ‘.doc’. There are specific file extensions
associated with the native application.
Vector Graphics - images defined using mathematics and geometry such as points, lines,
U0T31T 0T
curves, and shapes or polygon(s). Allowing for scalability. Objects and properties stored
mathematically.
Drawing objects and properties - Vector graphics are made up of objects and their properties.
An object is
a mathematical or geometrically defined construct such as a rectangle, line or circle.
<rect ... />
40T 40T 43T 41T43T
MUHAMMAD ALI KHAN
PAGE 20
31T
Analogue to Digital Converter (ADC) - Converts analogue sound into digital signals that can
be stored on a computer
Digital to Analogue Converter (DAC) - Converts digital signals stored on a computer into
analogue sound that can be played through devices such as speakers
Sound Sampling
So we should know by now that sound waves are continuous and computers can only store
discrete data.
How exactly does an Analogue to Digital Converter convert a continuous sound wave into
discrete digital data? To do this we need to look at how computers sample sound.
Sampling Rate - The number of samples taken per second
31TU U0T31T 0T
Hertz (Hz) - the SI unit of frequency defined as the number of cycles per second of a periodic
31TU U0T31T 0T
phenomenon
As you saw earlier, different sounds can have different volumes. The sampling resolution allows
you to set the range of volumes storable for each sample. If you have a low sampling resolution
then the range of volumes will be very limited, if you have a high sampling resolution then the
file size may become unfeasible. The sampling resolution for a CD is 16 bits used per sample.
31TU Bit rate - the number of bits required to store 1 second of sound
U0T31T 0T
To work out the size of a sound sample requires the following equation:
Sound Editing
If you are interested in sound editing you can start editing your own music using a program
called Audacity . Using Audacity you can create your own sound samples with different sample
0T 0T 31TU U 31T
rates and sample resolutions, listening to the difference between them and noting the different
file sizes.
Features
This is a list of features in Audacity, the free, open source, cross-platform audio editor.
Recording
Audacity can record live audio through a microphone or mixer, or digitize recordings from 0T 0T31TU
cassette tapes, records or minidiscs . With some sound cards, and on any Windows Vista,
U31T
Windows 7 or Windows 8 machine, Audacity can also capture streaming audio 0T 0T31TU U31T
Editing
1. Easy editing with Cut, Copy, Paste and Delete.
2. Unlimited sequential Undo (and Redo) to go back any number of steps.
3. Edit and mix large numbers of tracks.
4. Multiple clips are allowed per track.0T 0T31TU U0T 31T 0T
5. Label tracks with selectable Sync-Lock Tracks feature for keeping tracks and labels
31TU U0T31T 0T 0T 0T 31TU U0T31T 0T
synchronized.
6. Draw Tool to alter individual sample points.
7. Envelope Tool to fade the volume up or down smoothly.
31TU U0T31T 0T
Effects
Run-length encoding (RLE) is a very simple form of lossless data compression in which runs of
data (that is, sequences in which the same data value occurs in many consecutive data elements)
are stored as a single data value and count, rather than as the original run. This is most useful on
data that contains many such runs. Consider, for example, simple graphic images such as icons, line
drawings, and animations. It is not useful with files that don't have many runs as it could greatly
increase the file size.
For example, consider a screen containing plain black text on a solid white background. There will
be many long runs of white pixels in the blank space, and many short runs of black pixels within the
text. A hypothetical scan line, with B representing a black pixel and W representing white, might read
as follows:
WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW
With a run-length encoding (RLE) data compression algorithm applied to the above hypothetical
scan line, it can be rendered as follows:
12W1B12W3B24W1B14W
PAGE 26
!"#$%&'(')*)'"+, ')-.
%"+&/%/"#$%
'(*0'+*)'"+1
MUHAMMAD ALI KHAN
PAGE 28
Cambridge International AS & A Level Computer Science 9618 syllabus for 2021, 2022 and 2023. Subject content
2 Communication
2.1 Networks including the internet
Candidates should be able to: Notes and guidance
Show understanding of the purpose and benefits of
networking devices
Show understanding of the characteristics of a LAN
(local area network) and a WAN (wide area network)
Explain the client-server and peer-to-peer models of Roles of the different computers within the network
networked computers and subnetwork models
Benefits and drawbacks of each model
Justify the use of a model for a given situation
Show understanding of thin-client and thick-client
and the differences between them
Show understanding of the bus, star, mesh and hybrid Understand how packets are transmitted between
topologies two hosts for a given topology
Justify the use of a topology for a given situation
Show understanding of cloud computing Including the use of public and private clouds.
Benefits and drawbacks of cloud computing
Show understanding of the differences between and Describe the characteristics of copper cable, fibre-
implications of the use of wireless and wired networks optic cable, radio waves (including WiFi), microwaves,
satellites
Describe the hardware that is used to support a LAN Including switch, server, Network Interface Card
(NIC), Wireless Network Interface Card (WNIC),
Wireless Access Points (WAP), cables, bridge, repeater
Describe the role and function of a router in a network
Show understanding of Ethernet and how collisions Including Carrier Sense Multiple Access / Collision
are detected and avoided Detection (CSMA / CD)
Show understanding of bit streaming Methods of bit streaming, i.e. real-time and
on-demand
Importance of bit rates / broadband speed on bit
streaming
Show understanding of the differences between the
World Wide Web (WWW) and the internet
Describe the hardware that is used to support the Including modems, PSTN (Public Switched Telephone
internet Network), dedicated lines, cell phone network
PAGE 29
!"#$%&#&$'()*&%#+,-'.#/#0$1*2/-*/#"*%0,-3#45678#$&#/#9,))*9%$,"#,+#),9/)2/-*/#"*%0,-3:67&8#,-#
,%;*-#"*%0,-3&#%;/%#9,''<"$9/%*#0$%;#,"*#/",%;*-=##6#567#$&#*&&*"%$/))>#/#"*%0,-3#,+#"*%0,-3&.#
0$%;#%;*#!"%*-"*%#%;*#0,-)1?&#)/-@*&%#567=
A,1/>.#%;*-*#/-*#&*B*-/)#%>(*&#,+#567&.#C<$)%#+,-#/#B/-$*%>#,+#<&*#9/&*&#%;/%#%,<9;#B$-%</))>#*B*->#
/&(*9%#,+#',1*-"#)$+*=D,0#1$1#0$1*2/-*/#"*%0,-3$"@#&%/-%E
A;*#+$-&%#3",0"#567#0/	-*/%*1#C>#%;*#F=G=#6$-#H,-9*#$"#%;*#)/%*#IJKL&#%,#$"%*-9,""*9%#&$%*&#$"#
%;*#G*'$26<%,'/%$9#M-,<"1#N"B$-,"'*"%#4G6MN8#-/1/-#1*+*"&*#&>&%*'=#6"#*",-',<&#"*%0,-3#,+#
1*1$9/%*1#(;,"*#)$"*&.#%*)*(;,"*&.#/"1#',1*'&#)$"3*1#%;*#&$%*&#%,@*%;*-=
A;*#+,<"1/%$,"#,+#%;*#!O2C/&*1#!"%*-"*%#&%/-%*1#0$%;#%;*#61B/"9*1#P*&*/-9;#O-,Q*9%@*"9>#
7*%0,-3#46PO67NA8.#%;*#+$-&%#0$1*2/-*/#(/93*%2&0$%9;$"@#"*%0,-3#0$%;#1$&%-$C<%*1#9,"%-,)#/"1#
%;*#+$-&%#"*%0,-3#%,#$'()*'*"%#AROS!O#(-,%,9,)#&<$%*=
6PO67NA#$"$%$/))>#$"%*-9,""*9%*1#%;*#F"$B*-&$%>#,+#R/)$+,-"$/.#:,"@*)*FR:68.#%;*#G%/"+,-1#
P*&*/-9;#!"&%$%<%*#4",0#GP!#!"%*-"/%$,"/)8.#%;*#F"$B*-&$%>#,+#R/)$+,-"$/.#G/"%/#T/-C/-/#4FRGT8.#/"1#
%;*#F"$B*-&$%>#,+#F%/;=
!"#$%&'%#%!()%*+,$-*.
6#567#-,<%*-.#/)&,#3",0"#/&#/"#*1@*#-,<%*-#,-#C,-1*-#-,<%*-#$&#/#1*B$9*#%;/%#-,<%*/%/#(/93*%&#
C*%0**"#567#),9/%$,"&.#@$B$"@#/"#*"%*-(-$&*#/99*&&#%,#/#9/--$*-#"*%0,-3=##G*B*-/)#567#(-,%,9,)&#
;/B*#C**"#1*B*),(*1#,B*-#%$'*.#$"9)<1$"@#O/93*%#,B*-#GU7NASGVD#4O,G8.#W<)%$(-,%,9,)#:/C*)#
G0$%9;$"@#4WO:G8.#6AW.#/"1#H-/'*#P*)/>=
5;/%#$&#&,+%0/-*21*+$"*1#567#4GV25678E
G,+%0/-*21*+$"*1#567#4GV25678#$&#/"#/((-,/9;#+,-#'/3$"@#567#/-9;$%*9%<-*&#*/&$*-#%,#1*(),>.#
,(*-/%*.#/"1#'/"/@*=#!%#-*)$*&#,"#B$-%</)$X/%$,".#/(()$9/%$,"2)*B*)#(,)$9$*&#/"1#,B*-)/>#"*%0,-3&.#
/"1#,"&$%*#GV2567#1*B$9*&#/"1#&,+%0/-*#()/%+,-'&=
GV2567#$"9-*/&*/%/2%-/"&+*-#*++$9$*"9$*&#/9-,&&#/#567#C>#',B$"@#%-/++$9#%,#),0*-29,&%#
"*%0,-3#)$"3&#%,#1,#%;*#0,-3#,+#',-*2*Y(*"&$B*#)*/&*1#,-#WO:G#)$"*&=#
5;/%#$ȷ#,(%$'$X/%$,"E
:/%*"9>#/"1#C/"10$1%;#9,"&%-/$"%&#,+%*"#9/<&*#(*-+,-'/"9*#$&&<*&#$"#*"%*-(-$&*#567&=#567#
,(%$'$X/%$,"#<&*#/#B/-$*%>#,+#%*9;"$Z<*&.#$"9)<1$"@#1*1<()$9/%$,".#9,'(-*&&$,".#(-,%,9,)#
,(%$'$X/%$,".#%-/++$9#&;/($"@.#/"1#),9/)#9/9;$"@=#A;*&*#%*9;"$Z<*&#$'(-,B*#(/93*%#1*)$B*->#/"1#
%-/++$9#9,"%-,).#$"#%<-"#/)),0$"@#"*%0,-3#C/"10$1%;#%,#@-,0#,-#&;-$"3#1>"/'$9/))>#/&#"**1*1=
GV2567#%*9;",),@>#/"1#567#,(%$'$X/%$,"#9/"#C*#<&*1#&*(/-/%*)>#,-#%,@*%;*-=#G,'*#GV2567#
B*"1,-&#/-*#/11$"@#567#,(%$'$X/%$,"#+*/%<-*&#%,#%;*$-#(-,1<9%&
A>(*&#,+#567#%*9;",),@$*&
O/93*%#&0$%9;$"@
O/93*%#&0$%9;$"@#$&#/#'*%;,1#,+#1/%/#%-/"&'$&&$,"#$"#0;$9;#/#'*&&/@*#$&#C-,3*"#$"%,#&*B*-/)#(/-%&.#
9/))*1#(/93*%&.#%;/%#/-*#&*"%#$"1*(*"1*"%)>.#$"#%-$()$9/%*.#,B*-#0;/%*B*-#-,<%*#$&#,(%$'<'#+,-#*/9;#
(/93*%.#/"1#-*/&&*'C)*1#/%#%;*#1*&%$"/%$,"=#N/9;#(/93*%#9,"%/$"&#/#($*9*#(/-%.#9/))*1#%;*#(/>),/1.#
/"1#/"#$1*"%$+>$"@#;*/1*-#%;/%#$"9)<1**&%$"/%$,"#/"1#-*/&&*'C)>#$"+,-'/%$,"=#A;*#(/93*%&#/-*#
&*"%#$"#%-$()$9/%*#%,#9;*93#+,-#(/93*%#9,--<(%$,"=#NB*->#(/93*%#$&#B*-$+$*1#$"#/#(-,9*&&#%;/%#
9,'(/-*&#/"1#9,"+$-'&#%;/%#/%#)*/&%#%0,#9,($*&#'/%9;=#5;*"#B*-$+$9/%$,"#+/$)&.#/#-*Z<*&%#$&#'/1*#
+,-#%;*#(/93*%#%,#C*#-*2&*"%=
PAGE 31
!"#$%&'($)*$)+,-.$"
!"#$%&'#()*+#,-#,$./0#&$'+$1$0'+),'23)#0$144&'51)'/($+),35)3,#$)"1)$41,)')'/(+$)1+6$/,$
7/,6&/10$2#)7##($)"#$4,/-'0#,+$/8$1$,#+/3,5#$/,$+#,-'5#9$51&�$+#,-#,+9$1(0$+#,-'5#$
,#:3#+)#,+$51&�$5&'#()+;$<($)"#$5&'#()*+#,-#,$1,5"')#5)3,#9$7"#($)"#$5&'#()$5/.43)#,$+#(0+$
1$,#:3#+)$8/,$01)1$)/$)"#$+#,-#,$)",/3="$)"#$'()#,(#)9$)"#$+#,-#,$155#4)+$)"#$,#:3#+)#0$
4,/5#++$1(0$0#&'-#,$)"#$01)1$4156#)+$,#:3#+)#0$2156$)/$)"#$5&'#();$%&'#()+$0/$(/)$+"1,#$1(>$
/8$)"#',$,#+/3,5#+;[email protected]&#+$/8$%&'#()*A#,-#,$B/0#&$1,#$?.1'&9$C/,&0$C'0#$C#29$#)5;
/-0+&1$+!"#$%&'($)*$)+,-.$"+0-)23+4
<($)"'+$1,)'5&#$7#$1,#$=/'(=$)/$)16#$1$0'-#$'()/$)"#$%&'#()*A#,-#,$./0#&$1(0$"1-#$1$&//6$1)$
"/7$)"#$<()#,(#)$7/,6+$-'19$7#2$2,/7+#,+;$!"'+$1,)'5&#$7'&&$"#&4$3+$'($"1-'(=$1$+/&'0$
8/3(01)'/($/8$)"#$C?D$1(0$"#&4$'($7/,6'(=$7')"$C?D$)#5"(/&/='#+$7')"$#1+#;
!"#$%&5+C"#($7#$)1&6$)"#$7/,0$%&'#()9$')$.#1($)/$)1&6$/8$1$4#,+/($/,$1($/,=1('E1)'/($3+'(=$1$
41,)'53&1,$+#,-'5#;$A'.'&1,&>$'($)"#$0'=')1&$7/,&0$1$%&'#()$'+$1$5/.43)#,$FG/+)H$';#;$51412&#$/8$
,#5#'-'(=$'(8/,.1)'/($/,$3+'(=$1$41,)'53&1,$+#,-'5#$8,/.$)"#$+#,-'5#$4,/-'0#,+$FA#,-#,+H;
($)*$)35+A'.'&1,&>9$7"#($7#$)1&6$)"#$7/,0$A#,-#,+9$<)$.#1($1$4#,+/($/,$.#0'3.$)"1)$
+#,-#+$+/.#)"'(=;$A'.'&1,&>$'($)"'+$0'=')1&$7/,&0$1$A#,-#,$'+$1$,#./)#$5/.43)#,$7"'5"$
4,/-'0#+$'(8/,.1)'/($F01)1H$/,$155#++$)/$41,)'53&1,$+#,-'5#+;
A/9$')+$21+'51&&>$)"#$%&'#()$,#:3#+)'(=$+/.#)"'(=$1(0$)"#$A#,-#,$+#,-'(=$')$1+$&/(=$1+$')+$
4,#+#()$'($)"#$01)121+#;
!"#$%&$'()*+,*-./(%&01(2#(2*3+"(.4
!"#$%&'()"*+,-,$".+/($0+&''+*&$&+(#+&+,(#1'"+2'&3"4
!5,$+"66(3("#$+%"78(%",+'",,+.&(#$"#"+35,$+&#*+9&$&+%"35:"%-+(,+25,,(;'"4
<0"+3&2&3($-+56+$0"+!'("#$+&#*+="%:"%,+3&#+;"+30"*+,"2&%&$"'-4
5/)$"#$%&$'()*+,*-./(%&01(2#(2*3+"(.4
!'("#$,+&%"+2%5#"+$5+:(%8,",>+<%5?&#,+&#*+/5%.,+(6+2%","#$+(#+$0"+="%:"%+5%+82'5&*"*+(#$5+
$0"+="%:"%4
="%:"%+&%"+2%5#"+$5+9"#(&'+56+="%:(3"+@9A=B+&$$&3C,4
9&$&+2&3C"$,+.&-+;"+,2556"*+5%+.5*(6("*+*8%(#1+$%&#,.(,,(5#4
D0(,0(#1+5%+3&2$8%(#1+'51(#+3%"*"#$(&',+5%+5$0"%+8,"68'+(#65%.&$(5#+56+$0"+8,"%+&%"+35..5#+
&#*+EF<E@E&#+(#+$0"+E(**'"B+&$$&3C,+&%"+35..5#4
!
PAGE 33
!"#$%&"'(%)&#"%*"+"',-./#)0"#$+#"0/&*"10,-"0)*,/0')*"*#,0)2",&"+"')�+("*)03)0"%&*#)+2",1"+"
(,'+(%4)2"$+02"20%3)5"6$%&"'(%)&#*"7,08"9:"',&&)'#%&;"0)-,#)(:"#,"+"*)03)0<9+*)2"
',-./#%&;")&3%0,&-)&#"7$)0)"-,*#"+..(%'+#%,&*="*)&*%#%3)"2+#+="+&2"-)-,0:="+0)"!"#$%&'(
)*+,"'(%)&#*"$+3)"+"&/-9)0",1"9)&)1%#*="%&'(/2%&;>
-*."(.$%("*%(.&/.,".0%!(#1(.()*+,(23+%,"4
!"#$%&'()"*+,-
.#/�"*+1"02%($3
,45%67"*+5%6*20$(7($3
!61$+1&7(#81
9"46$"+:6%;+<6'2$(6#
!"#$%$&&'('$)*%+,),-$,.'/'*0
1(,/,.'/'*0
6$%&"'(%)&#"2).(,:-)&#"%*"-,0)"',*#")11)'#%3)"#$+&"2).(,:%&;"0);/(+0"?@*5"A)'+/*)"*,"
-/'$"%*"')�+(%4)2"+#"#$)"*)03)0<*%2)="#$%&"'(%)&#"',-./#%&;"'+&"0)2/')"B6"*/..,0#"+&2"
(%')&*%&;"',*#*5
C)'/0%#:"'+&"9)"%-.0,3)2"#$0,/;$")-.(,:%&;"#$%&"'(%)&#*"9)'+/*)"#$)"#$%&"'(%)&#"%#*)(1"%*"
0)*#0%'#)2"9:"#$)"*)03)05"6$%&"'(%)&#*"'+&&,#"0/&"/&+/#$,0%4)2"*,1#7+0)="+&2"2+#+"'+&D#"9)"
',.%)2",0"*+3)2"+&:7$)0)")E').#"1,0"#$)"*)03)05"C:*#)-"-,&%#,0%&;"+&2"-+&+;)-)&#"%*"
)+*%)0"9+*)2",&"#$)"')�+(%4)2"*)03)0"(,'+#%,&5
6$%&"'(%)&#*"'+&"+(*,"9)"*%-.()0"#,"-+&+;)="*%&')"/.;0+2)*="*)'/0%#:".,(%'%)*="+&2"-,0)"
'+&"9)"-+&+;)2"%&"#$)"2+#+"')&#)0"%&*#)+2",1",&"#$)")&2.,%&#"-+'$%&)*5"6$%*"()+2*"#,"
()**"2,7&#%-)="%&'0)+*%&;".0,2/'#%3%#:"+-,&;"B6"*#+11"+*"7)(("+*")&2.,%&#"-+'$%&)"/*)0*5
MUHAMMAD ALI KHAN
PAGE 36
!"#$%&'(#)*+,
!"#$%&$'#()*+,&-'+.&$-''(/&"(-01&$'#()*+,&-2(&34''53(-*42(/&$.674*(2+&*"-*&-2(&$.))($*(/&*.&
-&)(*8.2%9&:)'#%(&*"#)&$'#()*+,&8"#$"&'-$%&"-2/&/2#0(+&-)/&.*"(2&3(-*42(+,&*"#$%&$'#()*+&-2(&
34)$*#.)-'&8"(*"(2&*"(1&-2(&$.))($*(/&*.&-&)(*8.2%&.2&).*9
;"#'(&-&*"#$%&$'#()*&#+&34''1&34)$*#.)-'&8#*".4*&-&)(*8.2%&$.))($*#.),&#*&#+&.)'1&-&<$'#()*<&
8"()&#*&#+&$.))($*(/&*.&-&+(20(29&!"(&+(20(2&6-1&72.0#/(&*"(&*"#$%&$'#()*&8#*"&72.=2-6+&
-)/&3#'(+&*"-*&-2(&).*&+*.2(/&.)&*"(&'.$-'&6-$"#)(>+&"-2/&/2#0(9&?*&#+&).*&4)$.66.)&3.2&
8.2%7'-$(+&*.&72.0#/(&*"#$%&$'#()*+&*.&*"(#2&(67'.1((+9&!"#+&()-@'(+&*"(6&*.&-$$(++&3#'(+&
.)&-&'.$-'&+(20(2&.2&4+(&*"(&$.674*(2+&.33'#)(9&;"()&-&*"#$%&$'#()*&#+&/#+$.))($*(/&32.6&
*"(&)(*8.2%,&#*&#+&.3*()&2(3(22(/&*.&-+&-&8.2%+*-*#.)9
PAGE 37
!"#$%&'#%()(*(+,#-&./#0-12.-#2"#%/-#"-%3('4#2$#.(""-.%-0#%(#
&#.-"%'&*#0-12.-#.&**-0#/567#8"*24-#9-$/#%()(*(+,:#$%&'#%()(*(+,#0(-$";%#&**(3#02'-.%#
.(<<5"2.&%2("#6-%3--"#0-12.-$:#�-12.-#<5$%#/&1-#%(#.(<<5"2.&%-#%/'(5+/#/567#
!=#("-#0-12.-#3&"%$#%(#$-"0#0&%&#%(#(%/-'#0-12.-:#2%#/&$#%(#=2'$%#$-"0#%/-#0&%&#%(#/56#
&"0#%/-"#%/-#/56#%'&"$<2%#%/&%#0&%&#%(#%/-#0-$2+"&%-0#0-12.-7
!"#$%&$'()*+,*-&$.*&+/+0+'1
>7 ?-$$#-@)-"$21-#6-.&5$-#-&./#0-12.-#("*,#"--0#("-#!AB#)('%#&"0#"--0$#%(#6-
.(""-.%-0#32%/#/56#32%/#("-#*2"47
C7 D&$2-'#%(#2"$%&**
E7 ?-$$#&<(5"%#(=#.&6*-$#'-F52'-0#6-.&5$-#-&./#0-12.-#"--0$#%(#6-#.(""-.%-0
32%/#%/-#/56#("*,7
G7 H(65$%:#2=#("-#*2"4#=&2*$:#(%/-'#*2"4$#32**#3('4#I5$%#=2"-7
J7 D&$,#=&5*%#0-%-.%2("#6-.&5$-#%/-#*2"4#.&"#6-#-&$2*,#20-"%2=2-07
MUHAMMAD ALI KHAN
PAGE 40
!"#$%&'&(&)*
!"#$%&#'()(*(+,#'-./.#0#210"#31$*.#1"4#1**#'-.#4.503./.#3("".3'.4#'(#'-0Ò"#
31$*.#'-/(%+-#4/()#*0".&6#7-./.#0#4.503.#31**.4#'1)#'-1'#3("".3'&#'-.#4/()#*0".#'(#
'-.#210"#31$*.6#80"3.#1**#'-.#41'1#0&#'/1"&20''.4#(5./#'-.#210"#31$*.9#'-./.#0#*020'#(:#
4/()#*0"."4#'-.#40&'1"3.#1#210"#31$*.#31"#-15.6
;451"'1+.&#(:#$%&#'()(*(+,
<6 =1&,#0"&'1**1'0("9#.13-#31$*.#"..4&#'(#$.#3("".3'.4#>0'-#$13?$(".#31$*.6
@6 A.&$*.&#/.B%0/.4#'-1"#C.&-#1"4#&'1/#'()(*(+,
D0&1451"'1+.&#(:#$%&#'()(*(+,
<6 D0::03%*'*,#0"#:1%*'#4.'.3'0("6
@6 E('#&31*1$*.#1&#'-./.#0#*020'#(:#-(>#21",#"(4.&#,(%#31"#3("".3'#>0'-#$13?$(".
31$*.6
PAGE 41
!"#$%&'()*)+),"
PAGE 43
!"#$%&$'()*
!"#$%&'()*'*+,",&-+.
/00*##&1&)&,$
2-#,%(*3%4*"5.
6)*7&1&)&,$%8-3%93-:,4.
!88&0&*+,%3*0-;*3$.
+,)$"#$%&$'()*-
<-%)-+9*3%&+%0-+,3-)
="$%+-,%9*,%"))%,4*%8*",>3*#.
?-*#+@,%'*"+%$->%#4->)5%5-%":"$%:&,4%#*3;*3#.
<-%A*5>+5"+0$.
B"+5:&5,4%&##>*#.
MUHAMMAD ALI KHAN
PAGE 47
Benefits and drawbacks of using copper cables, fiber optic, radio waves, microwaves nd satellites
Copper cables
Common types are coaxial cable and twisted pair or unshielded twisted pair(UTP)
Advantages
Disadvantages
Fiber optics
Consist of a large number of very fine glass strands down which pulses of light can be sent
Advantage
" Because means of communication is light rather than electrical signal, the data will remain
inference
! free!
"! They are also very difficult to hack into!
"! The cables do not corrode!
" They have much greater bandwidth than metal cables!
Disadvantages
Radio waves
Radio waves have lower frequencies and longer wavelengths than microwaves. They are used to
transmit television and radio programs. They cannot transmit a lot of data simultaneously because
they are low frequencyContinued exposure to large amount of radio waves can cause health problems.
Despite these setbacks these can be used to transmit information from space t earth. Its frequency
ranges from 3 kHz to 300 kHz.
They travel at the speed of light in vacuum most commonly used in mobile radio communication,
computer networks, communication satellites, radar and broadcasting.
Microwaves
Microwaves are the electromagnetic or radio waves having higher frequencies so it can carry large
quantities of data. It is highly directional and transmits data between fixed positions. Wide bandwidth.
Less power requirement .some disadvantages include expensive towers and repeaters required also
subject to interference such as air plan, rain or building can disrupt microwave.
Satellites
It is a microwave repeater in space .it is a high bandwidth, coverage over a large geographical area and
can be cheaper over long distance.disadvantes include, huge initial cost, noise and interference,
propagation delay
!"#"$
!"#$%&'()%*$'+,-)#'$,.)',/'%0)'12$"+$3'4"!"'$%256$'/,#'4"#)()$$'!"6)("%7'256'"$'%0)'$2.)'
%0"58'2$'$27"58'49:;'<0"+0'$%256$'/,#'=4"#)()$$'9,+2(':#)2';)%<,#>3=
:'<"#)()$$'5)%<,#>'?$)$'#26",'<2-)$&'@?$%'(">)'+)(('A0,5)$&'%)()-"$",5$'256'#26",$'6,3'
B5'/2+%&'+,..?5"+2%",5'2+#,$$'2'<"#)()$$'5)%<,#>'"$'2'(,%'(">)'%<,C<27'#26",'
+,..?5"+2%",53'D)#)*$'<02%'02AA)5$E
:'+,.A?%)#*$'<"#)()$$'262A%)#'%#25$(2%)$'62%2'"5%,'2'#26",'$"852('256'%#25$."%$'"%'?$"58'
25'25%)5523
:'<"#)()$$'#,?%)#'#)+)"-)$'%0)'$"852('256'6)+,6)$'"%3'F0)'#,?%)#'$)56$'%0)'"5/,#.2%",5'
%,'%0)'B5%)#5)%'?$"58'2'A07$"+2(&'<"#)6'G%0)#5)%'+,55)+%",53
F0)'A#,+)$$'2($,'<,#>$'"5'#)-)#$)&'<"%0'%0)'#,?%)#'#)+)"-"58'"5/,#.2%",5'/#,.'%0)'
B5%)#5)%&'%#25$(2%"58'"%'"5%,'2'#26",'$"852('256'$)56"58'"%'%,'%0)'+,.A?%)#*$'<"#)()$$'
262A%)#3
MUHAMMAD ALI KHAN
PAGE 49
A server provides resource or service while a client requests for service. Client and servers
communicate over a computer network on separate hardware. Clients initiate communication
sessions with servers and await incoming requests.
Examples of computer applications that use the client server model are email, network
printing and World Wide Web.
Servers are classified by the services they provide e.web servers, serve WebPages and file
server serves computer files. Client and servers exchange messages in request-response-
messaging pattern. The language and rules of communication are defined in communication
protocols.
Example:
When a bank customer accesses online banking services with a web browser (the client),it
initiates a request to bank’s web server. The customer’s login credentials may be stored in a
database, and web server accesses the database server as a client. An application server
interprets the returned data by applying the bank’s business logic and provides the output to
the web server. Finally the web server returns the result to the client web browser for
display.
MUHAMMAD ALI KHAN
PAGE 50
Definition: The term “ WWW” refers to the “ World Wide Web” or simply the Web. The
0T 0T 0T 0T 0T 0T 0T 0T 0T 0T
World Wide Web consists of all the public Web sites connected to the Internet
worldwide, including the client devices (such as computers and cell phones) that access
Web content. The WWW is just one of many applications of the
Internet and computer networks.
The World Web is based on these technologies:
!"#$%&!'%(&!()&*+%&'+,(#+(,&
Networks
Network types
Routers
A router enables data to be routed between different networks, e.g between an Ethernet LAN and a
WAN of any description. It provides any necessary conversion of protocols from Ethernet to TCP/IP.
It can incorporate a firewall to provide network security. It stores information about which computer is
connected to which network. Router will inspect every packet of data being sent by any computer on
network connected to it. It connects at least two networks e.g. between LAN and WAN or a LAN and its
ISP.
Gateways
A gateway deals with different communication protocols between the receiving LAN and the other
networks. Gateway regulates traffic between two dissimilar networks while routers regulate traffic
between similar networks.e.g a device that allows a Windows NT network to communicate with a
NetWare network. Gateway acts as a network point that is entrance point to another network.
Servers
A network server is a computer designed to process requests and deliver data to other (client)
computers over a local network or the internet. Network servers are typically configured with
additional processing, memory and storage capacity to handle the load of servicing clients. Common
types of network servers include
!"#$%&
!"#$%&'()"*&+%,-"+*"."/01%+2'(%"#$%&'()"3(+45$"%-.%"0*$*"6!7".44($**$*"%'"8'(&.(4"4.%."
.%"%-$"4.%."1+#)"1.9$(":1.9$(";<"'8"%-$"=>?"/'4$1@">'/$"*&+%,-$*",.#".1*'"8'(&.(4"4.%.".%"
%-$"#$%&'()"1.9$(":1.9$("A<"39".44+%+'#.119"+#,'(2'(.%+#5"('0%+#5"80#,%+'#.1+%9@">0,-"
*&+%,-$*".($",'//'#19")#'&#".*"1.9$(BA"*&+%,-$*"'("/01%+1.9$("*&+%,-$*
MUHAMMAD ALI KHAN
PAGE 53
!"#$%&'()*#"&+,-"(-,&.(/!012(
!"#$%&'()"*#%$(+,-$"-,(."/0123"*4","5,(.&,($"-'67'#$#%"&*%5'8%"&5*-5","-'678%$("-,##'%"
9$"-'##$-%$."':$(","#$%&'();"1%"*4","-*(-8*%"9',(."*#4%,<<$."*#","-'678%$("%5,%"7(':*.$4","
.$.*-,%$."#$%&'()"-'##$-%*'#"%'"%5$"-'678%$(;"1%"*4",<4'"-,<<$."#$%&'()"*#%$(+,-$"-'#%('<<$(="
#$%&'()",.,7%$("'(">!0",.,7%$(;
34&5%6"
012",<<'&4"9'%5"&*($.",#."&*($<$44"-'668#*-,%*'#4;
012",<<'&4"-'668#*-,%*'#4"9$%&$$#"-'678%$(4"-'##$-%$.":*,"<'-,<",($,"#$%&'()
/>!03",4"&$<<",4"-'668#*-,%*'#4"':$("<,(?$@4-,<$"#$%&'()"%5('8?5"1#%$(#$%"A('%'-'<
/1A3;
012"*4"9'%5","75B4*-,<"<,B$(",#.",".,%,"<*#)"<,B$(".$:*-$="*;$;"*%"7(':*.$4"%5$"#$-$44,(B
5,(.&,($"-*(-8*%(B"4'"%5,%"%5$"75B4*-,<"<,B$("7('-$44$4",#."4'6$".,%,"<*#)"<,B$(
7('-$44$4"-,#"(8#"'#"*%;
7)&"8"66(*"#$%&'()*#"&+,-"(-%*#&%88"&(/7!012(
!"&*($<$44"#$%&'()"*#%$(+,-$"-'#%('<<$("/C0123"*4","#$%&'()"*#%$(+,-$"-'#%('<<$("&5*-5"-'##$-%4"
%'","&*($<$44"(,.*'@9,4$."-'678%$("#$%&'()="(,%5$("%5,#","&*($."#$%&'()="48-5",4"D')$#"E*#?"
'("F%5$(#$%;"!"C012="G84%"<*)$"'%5$("0124="&'()4"'#"%5$">,B$("H",#.">,B$("I"'+"%5$"JK1"L'.$<;"
D5*4"-,(."84$4",#",#%$##,"%'"-'668#*-,%$":*,"6*-('&,:$"(,.*,%*'#;"!"C012"*#",".$4)%'7"
-'678%$("*4"%(,.*%*'#,<<B"-'##$-%$."84*#?"%5$"A21"984;"J%5$("-'##$-%*:*%B"'7%*'#4",($"MKN",#."
A2"-,(.;"1#%$?(,%$."C0124",($",<4'",:,*<,9<$="/%B7*-,<<B"*#"L*#*"A21OA21"FP7($44"L*#*"2,(."
+'(63;
7)&"8"66(,--"66(5%)*#(/7932(
!"&*($<$44",--$44"7'*#%"/C!A3"*4","5,(.&,($".$:*-$"'("-'#+*?8($."#'.$"'#","<'-,<",($,"#$%&'()"
/>!03"%5,%",<<'&4"&*($<$44"-,7,9<$".$:*-$4",#."&*($."#$%&'()4"%'"-'##$-%"%5('8?5","&*($<$44"
4%,#.,(.="*#-<8.*#?"C*@Q*"'("N<8$%''%5;"C!A4"+$,%8($"(,.*'"%(,#46*%%$(4",#.",#%$##,$="&5*-5"
+,-*<*%,%$"-'##$-%*:*%B"9$%&$$#".$:*-$4",#."%5$"1#%$(#$%"'(","#$%&'();
!"!"#$%&'()&*+,""#$"%"&'()*+,-".,+/'-0#.1"2,3#&,"+4%+"&-,%+,$"%"$#.15,"%11-,1%+,".,+/'-0"
6-'("(*5+#)5,"&'((*.#&%+#'.".,+/'-0$"'-".,+/'-0"$,1(,.+$7"84#$"6*.&+#'."#$"&%55,2".,+/'-0"
9-#21#.17:;<"=-#21#.1"#$"2#$+#.&+"6-'("-'*+#.17">'*+#.1"%55'/$"(*5+#)5,".,+/'-0$"+'"&'((*.#&%+,"
#.2,),.2,.+5?"%.2"?,+"-,(%#."$,)%-%+,@"/4,-,%$"9-#21#.1"&'..,&+$"+/'"$,)%-%+,".,+/'-0$"%$"
#6"+4,?"/,-,"%"$#.15,".,+/'-07"A."+4,"BCA"('2,5@"9-#21#.1"#$"),-6'-(,2"#."+4,"2%+%"5#.0"5%?,-"
D5%?,-"EF7A6"'.,"'-"('-,"$,1(,.+$"'6"+4,"9-#21,2".,+/'-0"%-,"/#-,5,$$@"+4,"2,3#&,"#$"0.'/."%$"
%"/#-,5,$$"9-#21,7
!"#"$%"&
!"#$%&'()"*$+,-$"./$*"%'"($0$#$(1%$"'("($23,-1%$"1"/,0#134"5$2$1%$(/"1($"./$*",#"%(1#/6,//,'#"
/7/%$6/"%'"($0$#$(1%$"1#13'0"'("*,0,%13"/,0#13/"*,/%'(%$*"87"%(1#/6,//,'#"3'//4"!#13'0"($2$1%$(/"
9($:.$#%37"-1#"'#37"1623,97"%;$"/,0#13"&;,3$"*,0,%13"($2$1%$(/"-1#"($-'#/%(.-%"1"/,0#13"%'"#$1(",%/"
'(,0,#13":.13,%74
PAGE 54
The public switched telephone network is the aggregate of the world’s circuit switched telephone
networks that are operated by national, regional or local telephony operators, providing
infrastructure and services for public telecommunication.PSTN consists of telephone lines, fiber optic
cables, microwave transmission links, cellular networks communication satellites and undersea
telephone cables.
In relation to the internet, the PSTN actually furnishes much of the internet’s long distance
infrastructure. Internet service providers (ISP) pay the PSTN for access to their infrastructure and
share the circuit among many users though packet switching. Users pay usage tolls to their ISPs.
Bit streaming
A bit stream is a contiguous sequence of bits representing a stream of data transmitted continuously
over a communication path,serially.live streams are provide by means of called “true streaming”. It
sends the information straight to the computer without saving the file to hard disk e.g. during a
football game.
On-demand streaming is provide by means of “progressive streaming”. It saves the file to a hard disk
and then is played from that location.
A broadband speed of 2.5mbits/s or more is recommended for streaming movies. Storage size in
calculated from streaming bandwidth and length of media e.g.
Practical example: calculate the storage of one hour of video encoded at 300 Kbits/s
=128 MB
MUHAMMAD ALI KHAN
PAGE 58
IP addresses are binary numbers but they are usually stored as text files and displayed in human
readable notations such as 172.16.254.1
The maximum address is 255.255.255.255.in practice these are not enough for all the possible
computes so other techniques are used e.g. local addressing and subnetting
IP address has two parts. The first part of an IP address is used as network address, the last part as a
host address e.g.
192.168.123.____ network
___.___.____.132 host
Public IP address
A public IP address is assigned to every compute that connects to the internet where each IP is unique.
User has no control over the public IP address that is assigned to the computer. It is assigned by an ISP
(internet service provider).A public IP can be either static or dynamic. A static IP address does not
change and is used primarily for hosting WebPages or services on the internet
A dynamic IP address is chosen from a pool of available addresses and changes each time one connects
to the internet
Private IP address
The internet assigned numbers authority (IANA) has reserved ranges of IP addresses for private
networks. Private IP addresses are used for numbering the computers in a private network including
home, school and business LANs in airports and hotels. Private IP addresses are used to exchange files
and share resources within the private network. Different private networks could use the same IP
addresses because computers in different networks don’t directly communicate. A network router
passes the data back and forth. The router is assigned a public IP address by ISP.tis single IP address
identifies the entire network on the internet.
A URL is a formatted text string used by web browsers, email clients to identify a network resource
on the internt.URL string consists of three parts (sub strings)
I. Network protocol
II. Host name and address
III. File or resource location
E.g. protocol://host/location
The most commonly used protocols are http for viewing WebPages and FTP for transferring files over
the internet.
MUHAMMAD ALI KHAN
PAGE 59
A DNS server provides name resolution for TCP/IP based networks. It makes it possible to use name
rather than numeric IP addresses to identify remote hosts. A client computer sends the name of
remote host to a DNS server which responds with a corresponding IP address. If the DNS server does
not have an entry in its database for the remote host, it can respond to the client with the address of
DNS sever that is more likely to have information about that remote host or it can forward the request
to a different DNS server at next higher level in the hierarchy.
Explain how communication systems are used to support the Internet: The Public
Service Telephone Network (PSTN), dedicated lines, cell phone network
In relation to the Internet, the PSTN actually furnishes much of the Internet's long-distance
infrastructure.
Because Internet service providers ISP s pay the long-distance providers for access to their
0T 0T 31TU U31T
infrastructure and share the circuits among many users through packet-switching, Internet users
0T 0T
avoid having to pay usage tolls to anyone other than their ISPs.
MUHAMMAD ALI KHAN
PAGE 60
T h e F o rm a t o f a n IP A d d re s s
The format of an IP address is a 32-bit numeric address written as four numbers separated by periods. Each number
avoid duplicates.
S ta tic V e rs u s D yn a m ic IP A d d re ss e s
An IP address can be static or dynamic. A static IP address will never change and it is a permanent Internet address.
A dynamic IP address is a temporary address that is assigned each time a computer or device accesses the Internet.
The four numbers in an IP address are used in different ways to identify a particular network and a host on that
network. Four regional Internet registries -- ARIN, RIPE NCC, LACNIC and APNIC-- assign Internet addresses from
the following three classes:
Class A - supports 16 million hosts on each of 126 networks
The number of unassigned Internet addresses is running out, so a new classless scheme called CIDR is gradually
replacing the system based on classes A, B, and C and is tied to adoption of IPv6. In IPv6 the IP address size is
increased from 32 bits to 128 bits.
IP Addressing
IP addressing is a hardware-independent convention which in principle allows
every computer attached to the Internet to be given a unique logical address
(though we will see later on that there are some important exceptions to this).
IP addresses are currently 32-bit binary strings which are normally seen by
humans (e.g., network administrators, in dotted decimal as in the example:
223.58.1.10
IP Address Formats
Originally IP addresses were divided into five classes as shown below.
Classes A, B and C are the most important: the initial bits determine which
class an address belongs to, and the classes differ in how much of the
address is taken up with the network address and how much with the host
address.
Offsets
0 8 16 24
Class A
0 Network Host
10 Network Host
Exclusions
Some address ranges are excluded from the above classes. All addresses of
the form 127.xx.yy.xx are used for diagnostics. The following address ranges
are designated as "private": meaning thay can only be used on networks
which are not connected to the global Internet:
10.0.0.0 - 10.255.255.255
172.16.0.0.0 - 172.31.255.255
192.168.0.0 - 192.168.255.255
Examples
a. 4.23.145.90
b. 227.34.78.7
c. 246.7.3.8
d. 129.6.8.4
e. 198.76.9.23
Subnetting
The basic idea behind subnetting is that we take away some bits from the host
portion of the address and use them to identify the subnet. This will only be
visible to hosts and routers on the local network; from the point of view of the
Internet at large only the network ID portion will have any particular meaning.
The way this works is that the network administrator defines a subnet mask, a
string of 32 binary digits indicating the boundary between the subnet and host
sections of the "local" portion of an IP address. Some examples should help
make this clear:
This means that the first three bits from the host ID are used to
identify the subnet, and the remaining 5 bits indicate the host itself.
Take a host with the IP address
A. 255.0.0.0
B. 255.255.0.0
C. 255.255.255.0
D. N/A
E. N/A
Supernetting and Classless Inter-Domain Routing (CIDR)
CIDR is in a sense the converse of subnetting, in that bits are taken from the
network ID to identify a cluster of network addresses which are to be treated
as a single entity. The main reasons for this are:
CIDR uses a supernet mask along with the lowest network address in the
assigned block to identify the range of assigned network addresses.
MUHAMMAD ALI KHAN
PAGE 65
!"#$%$&'()*$(+),)-.(/0(,11&$++(-+(2")(.*,23$1(42)-5(-)(-+(6,24,557(.*,23$1(87()*$(2$)#"&9(
,16-2-+)&,)"&("&()*$(/2)$&2$)(:$&%-.$(0&"%-1$&(;/:0<=(>5+"'()*-+(,11&$++(1"$+(2")(.*,23$($,.*(
)-6$(#*$2()*$(4+$&(."22$.)+()"()*$(2$)#"&9=(/2(")*$&(#"&1+'()*$(1$%-.$(,5#,7+(4+$+()*$(+,6$(/0(
,11&$++()"(."22$.)()"()*$(-2)$&2$)=(?*$&$@"&$'()*$(+),)-.(/0(,11&$++-23(A&"%-1$+(645)-A5$(
,1%,2),3$+=(/)(3-%$+(6-2-646(1"#2)-6$(#*-5$(A&"%-1-23(&$6")$(,..$++=(>5+"'()*$(4+$&(.,2(
,..$++()*$(1$%-.$(@&"6(,27(5".,)-"2=
B*,)(-+(,(C72,6-.(/0(>11&$++
>(172,6-.(/0(,11&$++(-+(,2(,11&$++("8),-2$1(@&"6(,(C72,6-.(!"+)(D"2@-34&,)-"2(0&")"."5(
;C!D0<(+$&%$&=(/)(,++-32+(,(1$%-.$(#-)*(172,6-.(/0(,11&$++'(+482$)(6,+9'(1$@,45)(3,)$#,7'(,21(
,(CE:(+$&%$&=(/2(,(F-.&"+"@)(."6A4)$&'(+$5$.)-23()*$("A)-"2(G"8),-2(,2(/0(,11&$++(,4)"6,)-.,557H(
-2()*$(2$)#"&9(A&"A$&)7(#-21"#(#-55(+$)()*$(1$%-.$()"("8),-2(,2(/0(,11&$++(172,6-.,557=
?*$(172,6-.(/0(,11&$++(.*,23$+(@&$I4$2)57=(J,.*()-6$()*$(1$%-.$(."22$.)+()"()*$(2$)#"&9'()*$(
172,6-.(/0(,11&$++(.*,23$+=(B*$2()*$(1$%-.$()&-$+()"(."22$.)()"()*$(2$)#"&9'()*$(C!D0(+$&%$&(
A&"%-1$+(,(172,6-.(,11&$++=(B*$2()*$(4+$&()7A$+(,(KLM("2()*$(#$8(8&"#+$&'()*$(CE:(+$&%$&(
6,A+()*$(1"6,-2(2,6$()"()*$(/0(,11&$++=((N%$&,55'(C72,6-.(/0(,11&$++-23(-+(,4)"6,)-.(,21(-)(
6,9$+(6,2,3-23(,(2$)#"&9($,+-$&
PAGE 69
!"#$%&#$'(
)*%$+(
,$-"#$'(
.$/$+0(1"(&%(
."20
MUHAMMAD ALI KHAN
PAGE 71
Cambridge International AS & A Level Computer Science 9618 syllabus for 2021, 2022 and 2023. Subject content
Show understanding of the use of buffers Including their use in a range of devices and systems
Explain the differences between Random Access
Memory (RAM) and Read Only Memory (ROM) Include their use in a range of devices and systems
Explain the differences between Static RAM (SRAM)
and Dynamic RAM (DRAM)
Explain the difference between Programmable ROM and the reasons for using one instead of the other
(PROM), Erasable Programmable ROM (EPROM) and depending on the device and its use
Electrically Erasable Programmable ROM (EEPROM)
Show an understanding of monitoring and control Including:
systems
! difference between monitoring and control
! use of sensors (including temperature, pressure,
infra-red, sound) and actuators
! importance of feedback
PAGE 72
!"#$%&'(')*'+",$-&"$'*."'/.0$12,3'4-,#*1*0',#5'2%#6"&*$'1*'*%',#'"3"2*&12,3'
$17#,3'8.12.'2,#'9"'&",5'90',#'%9$"&6"&'%&'90',#0'"3"2*&%#12'1#$*&-+"#*'
31:"',#';<='2%#6"&*"&>';'$"#$%&'$*%&"$'*."'+",$-&"5'4-,#*1*0'*%'*."'
+"+%&0>
;?='@%#6"&*"&'(';#',#,3%7?*%?5171*,3'2%#6"&*"&'2%#6"&*$'*."',#,3%7'$17#,3
$"#*'90'*."'$"#$%&'1#*%','5171*,3'$17#,3>
A&%2"$$%&'B';!)@$'('A&%2"$$%&$'/&%2"$$'*."'5,*,'*%'+",$-&"'*."'%-*/-*'
,#5'$*%&"'1*'*%'*."'+"+%&0>
=?;'@%#6"&*"&'(';'5171*,3?*%?,#,3%7'2%#6"&*"&'2%#6"&*$'*."'5171*,3'5,*,'C"5
90'*."'/&%2"$$%&'*%',#,3%7'5,*,
;2*-,*%&'(';#',2*-,*%&'2%+/,&"$'*."'%-*/-*'716"#'90'*."'=?;'@%#6"&*"&'*%'
*."',2*-,3'D"E/"2*"5F'%-*/-*'$*%&"5'1#'1*',#5'$*%&"$'*."',//&%6"5'%-*/-*>
MUHAMMAD ALI KHAN
PAGE 74
Word/phrase Meaning
!"#$%#&'%()*+$,%-+$*+$%#).%/$-�'%.'1(2'/3%
455%2-6*+$()0%/7/$'6/%2#)%8'%8&-9')%.-:)%()$-%#%8#/(2%()*+$,%*&-2'//()0,%
-+$*+$%#).%/$-�'%6-.'5;%
Microphone
A BBC Bitesize GCSE revision guide to how sound is sampled, including an overview
diagram
http://www.bbc.co.uk/education/guides/z7vc7ty/revision
How microphones convert sound into an electrical signal
http://www.mediacollege.com/audio/microphones/how-microphones-work.html
Touchscreen
Describes resistive, capacitive and surface acoustic wave touchscreens
http://computer.howstuffworks.com/question716.htm
Resistive and capacitive touchscreens with diagrams
https://techexplainer.wordpress.com/2012/04/02/resistive-vs-capacitive-touchscreen/
Laser printer
How a laser printer works, based on a labelled diagram
http://www.computershopper.com/feature/how-it-works-laser-printer
Labelled diagram and explanation of laser printers
http://www.explainthatstuff.com/laserprinters.html
3D printer
!"#$%&'$%()*+&(,&%"+&-,.+/+,.+,%&,+01/'/+$&+2/*'(,(,3&45&/$(,%(,3&
"%%/6770008(,.+/+,.+,%8)#89:7*(;+<1%=*+73'.3+%1<',.<%+)"7;+'%9$+174.</$(,%(,3<
;#$<.9>>(+1<"#0<.#<4.</$(,%+$1<0#$:<?@@?A4B8"%>*&&
MUHAMMAD ALI KHAN
PAGE 76
Speakers
Explains sound signals, how the voice coil produces sound, and differences between
computer speakers and other speakers
http://www.ehow.com/how-does_4963948_how-computer-speakers-work.htmlHard disk
Description and labelled diagram of the parts in a hard disk
http://www.explainthatstuff.com/harddrive.html
Page 5 onwards: a more detailed explanation of the parts of a hard disk
http://computer.howstuffworks.com/hard-disk4.htm
Optical discs
Basic description of the operation of optical discs in BBC Bitesize Higher Computing
Science http://www.bbc.co.uk/education/guides/zws3gk7/revision/3
Solid state (flash) memory
An accessible simple description of flash memory, followed by a more detailed explanation
http://www.explainthatstuff.com/flashmemory.html
3.2.Videos
The following are all very brief videos that explain the principles of the
How a touchscreen works
https://www.youtube.com/watch?v=euCewYGHZB0
How a scanner works
https://www.youtube.com/watch?v=shnYIjG20i4
How a laser printer works
https://www.youtube.com/watch?v=WB0HnXcW8qQ
How a 3D printer works
https://www.youtube.com/watch?v=Vx0Z6LplaMU
How a hard disk works
https://www.youtube.com/watch?v=4iaxOUYalJUHow an optical drive works https://
www.youtube.com/watch?v=bRDuAa6nhpw
How solid state memory works
https://www.youtube.com/watch?v=TFoOyPXYJ-E&feature=youtu.be
PAGE 77
!"#$%&'
A sensor is a device that detects events or changes in quantities and provides a corresponding
output, generally as an electrical or optical signal. They can produce a stream of input data
automatically without any human intervention. Usually this is an analogue signal so it needs
to be converted into digital data for the computer to process. This is done using by an
Analogue-to-Digital Converter (ADC). Sensors are used extensively in monitoring
/ measuring / data logging systems, and also in computer control systems. Following is the
list of commonly used sensors:
Temperature
Magnetic Field Gas
Pressure Moisture
Humidity
Ph/Acidity/Alkalinity
Motion/ Infra-Red
A temperature sensor produces a signal that depends on the temperature of its surroundings.
The computer process the digitize signal to display a measurement or to control an appliance.
We can use temperature sensor in many appliance such:
!" Automatic washing machine#
$" Digital thermometer#
%" Controlling heating system in buildings, including greenhouses and chemical reaction
vessels.#
/&"$$-&".$"#$%&'
A pressure sensor produces a signal that depends on the pressure to which it is exposed.
Pressure sensor can be used in many appliances such as automatic blood pressure monitor.
Pressure sensor can also control the pressure of gases or liquids in chemical reaction vessel.
0+1#",23.42"56'
The Magnetic Field Sensor can be used to study the field around permanent magnets, coils,
and electrical devices. This sensor uses a Hall effect transducer, and measures a vector
component of the magnetic field near the sensor tip. It has two ranges, allowing for
measurement of relatively strong magnetic fields around permanent magnets and
electromagnets, as well as measurement of weak fields such as the Earth’s magnetic field. The
articulated sensor tip allows you to measure both transverse and longitudinal magnetic fields.
7+$'
A gas sensor produces a signal depending on the concentration of a particular gas or vapor.
We can use gas sensor for an inflammable gas to monitor the atmosphere and sound an alarm
if there is a leakage. We can use gas sensor in other applications such as:
& Breathalyzer, which measure the concentration of alcohol vapour in a sample of
breath and estimate the concentration of alcohol in blood.#
MUHAMMAD ALI KHAN
PAGE 79
#
& Process control in chemical industry.#
& Environment monitoring of air pollution#
0%2$,-&"8.9-)262,:.$"#$%&#
A moisture sensor produces a signal that depends on the concentration of water vapors in the
atmosphere. A moisture sensor can control an irrigation system more efficiently only allow
water
# when soil is dry. We can use moisture sensor in many other application including:#
& Controlling a heating system and air conditioning system.#
& Maintaining sufficient humidity in the air in a greenhouse.#
& Measuring humidity for meteorological record and forecasting in a weather station.#
/98+3262,:8+5;+52#2,:.$"#$%&'#
PH Sensor measures the pH of aqueous solutions in industrial and municipal process applications. It is
designed to perform in the harshest of environments, including applications that poison conventional
pH sensors.
Typical activities using our pH sensor include:
& Acid-base titrations#
& Studies of household acids and bases#
& Monitoring pH change during chemical reactions or in an aquarium as a result of
# photosynthesis#
& Investigations of acid rain and buffering#
& Analysis of water quality in streams and lakes#
<#=&+&"6.$"#$%&'
An infra (IR) sensor produces a signal that depends on the level of invisible IR radiation falling on it.
All objects (unless they are extremely cold) emit significant IR radiation. Security camera equips with
lens and grid of IR sensors uses this IR radiation to form a detector for a person.
!3+##"&
Scanners are used to enter hardcopy images into a computer. The most common type is the
flatbed scanner where the user places the document flat on a glass panel and closes the lid.
An array of light sensors and a light source move underneath the document.
The sensor ‘reads’ the light reflected from the document or image. Most scanners use
charged-coupled device (CCD) array. Regardless of the technology used, a sensor array
contains light-sensitive diodes that convert analog light waves into a digital signal. Some
scanner arrays contain three rows of sensors. Each row is calibrated to measure red, blue
or green light.
MUHAMMAD ALI KHAN
PAGE 80
>",2#+.$3+##"&
The human retina is a thin tissue composed of
neural cells that is located in the posterior
portion of the eye. Because of the complex
structure of the capillaries that supply the
retina with blood, each person's retina is
unique. The network of blood vessels in the
retina is not entirely genetically determined
and thus even identical twins do not share a
similar pattern.
A retinal scan is performed by casting an
unperceived beam of low-energy infrared
light into a person’s eye as they look through the scanner's eyepiece. This beam of light traces
a standardized path on the retina. Because retinal blood vessels absorb light more readily
than the surrounding tissue, the amount of reflection varies during the scan. The pattern of
variations is digitized and compared with already stored patterns to verify the identity of the
person.
MUHAMMAD ALI KHAN
PAGE 81
42#1"&*&2#,.$3+##"&
The scanning process starts when you place your finger on a glass plate, and a CCD camera
takes a picture. The scanner has its own light source, typically an array of light-emitting
diodes, to illuminate the ridges of the finger. The CCD system actually generates an inverted
image of the finger, with darker areas representing more reflected light (the ridges of the
finger) and lighter areas representing less reflected light (the valleys between the ridges). If
the processor finds that the image is crisp and properly exposed, it proceeds to comparing
the captured fingerprint with fingerprints on file.
MUHAMMAD ALI KHAN
PAGE 82
?+$"&.*&2#,"&
This type of printer produces very
high quality hard copy. It consists
of drum that is electrically charged.
A laser is used to change the charge
on the drum for each dot of the
output to be produced. Electrically
charged toner is then attracted to
the oppositely charged dots. The
paper presses against the
toner coated drum and is output with the pattern of dots required which is then heated in
order to permanently fuse the text/imagery. The page cannot be printed until the whole
document has been stored in a large buffer.
!*"+;"&$
It is a device which produces sound as output. The digital data from the computer is converted
into analogue signals by a digital to analogue converter and are then amplified and output
using the speakers. At the front of a loudspeaker, there is a fabric, plastic, paper, or
lightweight metal cone. The inner part is fixed to an iron coil (sometimes called the voice coil)
that sits just in front of a permanent magnet (sometimes called the field magnet). when
electric current is passed through coil; it
becomes a temporary magnet
(electromagnet). As the electricity flows back
and forth in the cables, the electromagnet
either attracts or repels the permanent
magnet. This moves the coil back and forward,
pulling and pushing the loudspeaker cone
which produces sound.
MUHAMMAD ALI KHAN
PAGE 83
@+3;2#1.$,%&+1"'
Backing storage (also called auxiliary storage) stores programs and data for future use. In
order to store data while the electricity is switched off or unavailable storage must be non-
volatile. Access to backing storage is slower than internal memory. Operating systems and
program files are loaded into RAM from backing storage when required for execution. It is
important to distinguish between a storage device and storage medium. The storage device
is the machine that stores data; the storage medium is the material on which the device
stores data. There are three different types of backing storage device:
9+&6.62$;.A!"#$%&'()*&+,"#%B
Hard disk is a type of magnetic storage.
It consists of one or more disks
(depending upon the capacity of hard
disk).They are mounted on a spindle
which is operated by a motor to spin
the disk very quickly. There is usually
one read/write head for each disk
surface being used. The disks are used
to store operating system as well as
software programs and data files. It
provides very fast access to data for
both reading from and writing to the
disks.
MUHAMMAD ALI KHAN
PAGE 84
C*,23+5.62$;
optical disc recording
technologies, an optical disc (OD)
is a flat, usually circular disc which
encodes binary data (bits) in the
form of pits (binary value of 0 or
off, due to lack of reflection when
read) and lands
(binary value of 1 or on, due to a reflection when read) on a special material (often aluminum)
on one of its flat surfaces.
!%526.$,+,".)")%&:
Solid state storage is a type of computer storage media that is made from silicon microchips.
it stores data electronically instead of magnetically, as spinning hard disk drives or magnetic
tape do.
An important advantage of solid-state storage is the fact that it contains no mechanical parts,
allowing data transfer to and from storage media to take place at a much higher speed and
providing a more predictable lifespan for the storage media. In addition to providing faster
and more consistent input/output (I/O) times, solid-state storage media offers the same levels
of
data integrity and endurance as
other electronic devices and
requires less power and cooling
than its electromechanical
equivalents. It also generally
weighs less.
MUHAMMAD ALI KHAN
PAGE 85
D3,-+,%&$
Actuators are used to convert computer signal into movement. Some devices such as motors
are considered to be actuators in their own right. The most common form of motor used with
computers is the stepper motor which moves n steps that can be very tiny, enabling precise
control .e.g. in home they are used in washing machines to make the drum go round. They
cause the water pumps to come on in central heating systems. They are also used in computer
controlled green houses to open the windows and switch on fans.
Buzzers
An actuator is connected from the computer to the buzzer. The actuator is set to switch the
buzzer either on or off. In the same way lights and heaters can be switched on or off.
MUHAMMAD ALI KHAN
PAGE 86
/&2)+&:.%&.0+2#.)")%&:
Main store (or computer !"!#$%) is divided into Read Only Memory (ROM) and
Random Access Memory (RAM).
!"#
!"#$is memory that cannot be changed by a$&$#'$(!$or user. ROM retains its memory$
even after the computer is turned off. For example, ROM stores the instructions for the
computer to start up when it is turned on again.
%&'(&)**)+,-$&-).$'/,0$*-*'&0$1%!"#2
A PROM is a memory chip on which data can be written only once. Once a program has
been written onto a PROM, it is permanent. Unlike RAM, PROM's retain their contents
when the computer is turned off. The difference between a PROM and a ROM (read
only memory) is that a PROM is manufactured as a blank memory, whereas a ROM is
programmed during the manufacturing process. To write data onto a PROM chip, a
special device called a PROM programmer or PROM burner is required.
3&)4)+,-$5&'(&)**)+,-$&-).$'/,0$*-*'&0$13%!"#2
This is a special type of PROM that can be erased by exposing it to ultraviolet (UV) light.
Once it has been erased, it can be re-programmed using an EPROM burner.
MUHAMMAD ALI KHAN
PAGE 87
3,-67&86),,0$-&)4)+,-$5&'(&)**)+,-$&-).$'/,0$*-*'&0$133%!"#2
An EEPROM is a special type of PROM that can be erased by exposing it to an electrical charge. Like
other types of PROM, EEPROM retains its contents even when the power is turned off.
!9#
!9#$is a fast 7-*5'&)&0 type of
memory in which
programs, (&&)*+(,*#-. and /(,( are
stored. Here are some examples of what's
stored in RAM:
& the #&"$(,*-'0.%.,"!#
&# applications#
&# the graphical user interface (GUI)#
If a computer loses power, all data stored
in its RAM is lost.#
RAM
# exist called SRAM (static RAM) and#
DRAM (dynamic RAM) – SRAM doesn’t need to be constantly refreshed to retain its memory
unlike DRAM. Also note that computers use cache which is a portion of memory made from
SRAM. Memory caching works since programs usually access the same data or instructions
over and over again.#
PAGE 88
Cambridge International AS & A Level Computer Science 9618 syllabus for 2021, 2022 and 2023. Subject content
LDD <address> Direct addressing. Load the contents of the location at the given address to
ACC
LDI <address> Indirect addressing. The address to be used is at the given address. Load the
contents of this second address to ACC
LDX <address> Indexed addressing. Form the address from <address> + the contents of the
index register. Copy the contents of this calculated address to ACC
LDR #n Immediate addressing. Load the number n to IX
MOV <register> Move the contents of the accumulator to the given register (IX)
ADD <address> Add the contents of the given address to the ACC
SUB <address> Subtract the contents of the given address from the ACC
DEC <register> Subtract 1 from the contents of the register (ACC or IX)
CMP <address> Compare the contents of ACC with the contents of <address>
CMI <address> Indirect addressing. The address to be used is at the given address. Compare the
contents of ACC with the contents of this second address
JPE <address> Following a compare instruction, jump to <address> if the compare was
True
JPN <address> Following a compare instruction, jump to <address> if the compare was
False
IN Key in a character and store its ASCII value in ACC
OUT Output to the screen the character whose ASCII value is stored in ACC
All questions will assume there is only one general purpose register available (Accumulator)
ACC denotes Accumulator
IX denotes Index Register
<address> can be an absolute or symbolic address
# denotes a denary number, e.g. #123
B denotes a binary number, e.g. B01001010
& denotes a hexadecimal number, e.g. &4A
MUHAMMAD ALI KHAN
PAGE 93
Cambridge International AS & A Level Computer Science 9618 syllabus for 2021, 2022 and 2023. Subject content
Instruction
Label Opcode Operand Explanation
AND #n Bitwise AND operation of the contents of ACC with the operand
AND <address> Bitwise AND operation of the contents of ACC with the contents
of <address>
XOR #n Bitwise XOR operation of the contents of ACC with the operand
XOR <address> Bitwise XOR operation of the contents of ACC with the contents
of <address>
OR #n Bitwise OR operation of the contents of ACC with the operand
OR <address> Bitwise OR operation of the contents of ACC with the contents of
<address>
<address> can be an absolute address or a symbolic address
LSL #n Bits in ACC are shifted logically n places to the left. Zeros are
introduced on the right hand end
LSR #n Bits in ACC are shifted logically n places to the right. Zeros are
introduced on the left hand end
<label>: <opcode> <operand> Labels an instruction
<label>: <data> Gives a symbolic address <label> to the memory location with
contents <data>
MUHAMMAD ALI KHAN
PAGE 94
! Op code (abbreviated from operation code) is the portion of a machine language instruction
" that specifies the operation to be performed"
! Operand address or data on which the operation is to be performed."
Addressing modes
" ! Immediate"
! Direct"
! Indirect"
! Indexed"
! Relative"
Immediate addressing
Immediate addressing means that the data to be used is hard-coded into the instruction
itself.This is the fastest method of addressing as it does not involve main memory at all.
ADD #2
Nothing has been fetched from memory; the instruction simply adds 2 to the accumulator
Direct addressing
This is a very simple way of addressing memory - direct addressing means the code refers
directly to a location in memory
In this instance the value held at the absolute location 3001 in RAM is subtracted from the
accumulator. The good thing about direct addressing is that it is fast (but not as fast as
immediate addressing) the bad thing about direct addressing is that the code depends
on the correct data always being present at same location.
You could use direct addressing on computers that are only running a single program. For
example an engine management computer only ever runs the code the car engineers
programmed into it, and so direct memory addressing is excellent for fast memory access.
MUHAMMAD ALI KHAN
PAGE 96
Indirect addressing
MUHAMMAD ALI KHAN
PAGE 97
Indexed addressing
The address is formed by the operand plus the number in the index register.
CIR
ADI 10 10 200
.
IR(index register) + .
150 .
160 120
accumulator
120 .
200 395
Index addressing is fast and is excellent for manipulating data structures such as arrays as
all you need to do is set up a base address (e.g. 10 in CIR) then use the index in your code
to access individual elements. Another advantage of indexed addressing is that if the array
is re-located in memory at any point then only the base address needs to be changed. The
code making use of the index can remain exactly the same.
Relative addressing
Quite often a program only needs to jump a little bit in order to jump to the next instruction.
Maybe just a few memory locations away from the current instruction. A very efficient way of
doing this is to just add a small offset to the current address in the program counter.
(Remember that the program counter always points to the next instruction to be
executed).This is called 'relative addressing'
DEFINITION:
Relative addressing means that the next instruction to be carried out is an offset number
of locations away, relative to the address of the current instruction. Consider this bit of
pseudo-code:
jmp +3 if accumulator == 2
Code executed if accumulator is NOT = 2
jmp +5 (unconditional relative jump to avoid the next line of code)
acc:
Code executed if accumulator is = 2)
Carry on:
In the code snippet above, the first line of code is checking to see if the accumulator has the
value of 2 in it. If it is has, then the next instruction is 3 lines away. This is called a conditional
jump and it is making use of relative addressing.
Another example of relative addressing can be seen in the jmp +5 instructions. This is telling the
CPU to effectively avoid the next instruction and go straight to the 'carryon' point.
MUHAMMAD ALI KHAN
PAGE 98
!"#$%&#$'()$*+$(%$'%$,(-"%(%"(
'.")("/+()$01-$''$'2(3/%(%"(
,&'4"5$+("/+('%+$-6%.'7
MUHAMMAD ALI KHAN
PAGE 102
Cambridge International AS & A Level Computer Science 9618 syllabus for 2021, 2022 and 2023. Subject content
4 Processor Fundamentals
4.1 Central Processing Unit (CPU) Architecture
Candidates should be able to: Notes and guidance
Show understanding of the basic Von Neumann
model for a computer system and the stored program
concept
Show understanding of the purpose and role of Special purpose registers including:
registers, including the difference between general
! Program Counter (PC)
purpose and special purpose registers
! Memory Data Register (MDR)
! Memory Address Register (MAR)
! The Accumulator (ACC)
! Index Register (IX)
! Current Instruction Register (CIR)
! Status Register
Show understanding of the purpose and roles of the
Arithmetic and Logic Unit (ALU), Control Unit (CU)
and system clock, Immediate Access Store (IAS)
Show understanding of how data are transferred
between various components of the computer system
using the address bus, data bus and control bus
Show understanding of how factors contribute to the Including:
performance of the computer system
! processor type and number of cores
! the bus width
! clock speed
! cache memory
Understand how different ports provide connection to Including connection to:
peripheral devices
! Universal Serial Bus (USB)
! High Definition Multimedia Interface (HDMI)
! Video Graphics Array (VGA)
Describe the stages of the Fetch-Execute (F-E) cycle Describe and use ‘register transfer’ notation to
describe the F–E cycle
Show understanding of the purpose of interrupts Including:
! possible causes of interrupts
! applications of interrupts
! use of an Interrupt service (ISR) handling routine
! when interrupts are detected during the fetch-
execute cycle
! how interrupts are handled
MUHAMMAD ALI KHAN
PAGE 103
A register is simply a location that can store extremely limited amount of instruction or data
only immediately before or after processing. The registers are outside the immediate access
store and consequently allow faster access to the data they store.
Role of arithmetic logic unit (ALU), control unit (CU) and system clock
!"#$%"&' (#)$! The control unit is a component of a computer's central processing unit
(CPU) that directs operation of the processor. It tells the computer's memory, arithmetic/
logic unit and input and output devices how to respond to a program's instructions.
It directs the operation of the other units by providing timing and control signals. All
computer resources are managed by the CU (Control Unit).It directs the flow of data between
the Central Processing Unit (CPU) and the other devices.
MUHAMMAD ALI KHAN
PAGE 105
System clock
Every computer contains an internal clock that regulates the rate at which instructions are
executed and synchronizes all the various computer components. The CPU requires a fixed
number of clock ticks (or $,($-+$.$,"/) to execute each instruction. The faster the clock, the
more instructions the CPU can execute per second.
Clock speeds are expressed in mega hertz (MHz) or giga hertz ((GHz).
An address bus is a computer bus (a series of lines connecting two or more devices) that is
used to specify the address from/to which the CPU wishes to read or write. The number of
bits of address bus determines the maximum size of memory which the processor can access.
For example, a system with a 32-bit address bus can address 232 (4,294,967,296) memory
locations. If each memory address holds one byte, the addressable memory space is 4 GB.
Data bus
Data bus is used to carry the data that needs to be transferred from one hardware component
to another. The memory data register (MDR) is at one end of the data bus. The data bus is
bi-directional because same bus is used for data transmission from microprocessor to memory
location or input/output device and vice versa.
MUHAMMAD ALI KHAN
PAGE 106
Control bus
Control bus is used to send control signals from the control unit to the other components of
the system. A separate wire is dedicated to a particular control signal e.g.
How bus width and clock speed affect the performance of the computer system
" The clock speed (or clock rate) is stated in megahertz (MHz) or gigahertz (GHz),
and refers to the speed at which the processor can execute instructions. The faster
! the clock, the more instructions the processor can complete per second.!
" The number of wires in data bus determines the quantity of data that the bus
can carry at any one time.!
" Increasing the data bus will increase the quantity of data the bus can carry at
one time so speeds up the performance/processing of the computer!
A compute with a data bus of 32 lines is called a 32 bit computer and word length
is 32.
MUHAMMAD ALI KHAN
PAGE 107
Ports:
" Program counter (PC) - an incrementing counter that keeps track of the memory
address of the instruction that is to be executed next.!
" Memory address register (MAR) - holds the address of a memory block to be read
from or written to.!
" Memory data register (MDR) - a two-way register that holds data fetched from
memory (and ready for the CPU to process) or data waiting to be stored in memory.!
" Current Instruction register (IR) - a temporary holding ground for the instruction
that has just been fetched from memory.!
" Control unit (CU) - decodes the program instruction in the IR, selecting machine
resources such as a data source register and a particular arithmetic operation, and
coordinates activation of those resources.!
" Arithmetic logic unit (ALU) - performs mathematical and logical operations.!
MUHAMMAD ALI KHAN
PAGE 112
After increment
MUHAMMAD ALI KHAN
PAGE 114
4. The MBR loads the Current Instruction Register with the instruction to be executed.
!"#$%"$&$'("")*$+*,#**-$."/*$0/"'*))"/$'"/*)$"/$1$(23(*/$'4"'5$)0**%6
"#!$%!&%'()*'%+!,%-*.%/!,*(0!1.*2%##*.!2*.%#!3'+!24*25!#1%%+!3.%!%##%'()34!(*!*1%.3()'6!7*8.!
2*&18(%.9!:87)'6!3!2*&18(%.!$)(0!&84()14%!2*.%#!3'+!3!#81%.!0)60!24*25!#1%%+!#*8'+#!)+%34!;!,8(!
$03(!+*%#!(0)#!344!.%3447!&%3'!-*.!-8'2()*'34)(7!)'!7*8.!2*&18(%.<
:3#)23447/!03=)'6!3!0)60!24*25!#1%%+!,8(!>8#(!*'%!*.!($*!2*.%#!&%3'#!7*8.!2*&18(%.!$)44!,%!3,4%!(*!
4*3+!3'+!)'(%.32(!$)(0!3!#)'64%!3114)23()*'!?8)25479!@*'=%.#%47/!03=)'6!&*.%!1.*2%##*.!2*.%#/!,8(!3!
#4*$%.!24*25!#1%%+!&%3'#!7*8.!2*&18(%.!23'!$*.5!$)(0!&*.%!3114)23()*'#!3(!3!()&%/!,8(!%320!&37!
.8'!3!4)((4%!#4*$%.9
A0%'!2*&13.)'6!2*&18(%.#/!)(B#!&*#(!)&1*.(3'(!(*!(0)'5!3,*8(!7*8.!*$'!4)-%#(74%9!C*(!%=%.7*'%!
'%%+#!(0%!#3&%!4%=%4!*-!1.*2%##)'6!#1%%+#!*.!2*.%#9!A%B44!+)#28##!0*$!63&)'6!2*&18(%.#!3'+!+37;(*;
+37!$*.5!*.!1%.#*'34!2*&18(%.#!+)--%.!$0%'!)(!2*&%#!(*!(0%#%!-%3(8.%#!)'!3!,)(9!D).#(/!$%B44!6%(!)'(*!
$03(!(0%#%!&%3'!-*.!431(*1!3'+!+%#5(*1!2*&18(%.#9
PAGE 115
An instruction set is a group of commands for a CPU in machine language. The instruction
set consists of multiple pieces, including addressing modes, instructions, native data types,
registers, memory architecture, interrupt, exception handling and external I/O.
Complex instruction set computer (CISC) has many specialized instructions, some of
which may only be rarely used in practical programs.
" Op code (abbreviated from operation code) is the portion of a machine language instruction
! that specifies the operation to be performed!
" Operand address or data on which the operation is to be performed.!
Addressing modes
! " Immediate!
" Direct!
" Indirect!
" Indexed!
" Relative!
Immediate addressing
Immediate addressing means that the data to be used is hard-coded into the instruction
itself.This is the fastest method of addressing as it does not involve main memory at all.
ADD #2
Nothing has been fetched from memory; the instruction simply adds 2 to the accumulator
Direct addressing
This is a very simple way of addressing memory - direct addressing means the code refers
directly to a location in memory
In this instance the value held at the absolute location 3001 in RAM is subtracted from the
accumulator. The good thing about direct addressing is that it is fast (but not as fast as
immediate addressing) the bad thing about direct addressing is that the code depends
on the correct data always being present at same location.
You could use direct addressing on computers that are only running a single program. For
example an engine management computer only ever runs the code the car engineers
programmed into it, and so direct memory addressing is excellent for fast memory access.
MUHAMMAD ALI KHAN
PAGE 120
Indirect addressing
MUHAMMAD ALI KHAN
PAGE 121
Indexed addressing
The address is formed by the operand plus the number in the index register.
CIR
ADI 10 10 200
.
IR(index register) + .
150 .
160 120
accumulator
120 .
200 395
Index addressing is fast and is excellent for manipulating data structures such as arrays as
all you need to do is set up a base address (e.g. 10 in CIR) then use the index in your code
to access individual elements. Another advantage of indexed addressing is that if the array
is re-located in memory at any point then only the base address needs to be changed. The
code making use of the index can remain exactly the same.
Relative addressing
Quite often a program only needs to jump a little bit in order to jump to the next instruction.
Maybe just a few memory locations away from the current instruction. A very efficient way of
doing this is to just add a small offset to the current address in the program counter.
(Remember that the program counter always points to the next instruction to be
executed).This is called 'relative addressing'
DEFINITION:
Relative addressing means that the next instruction to be carried out is an offset number
of locations away, relative to the address of the current instruction. Consider this bit of
pseudo-code:
jmp +3 if accumulator == 2
Code executed if accumulator is NOT = 2
jmp +5 (unconditional relative jump to avoid the next line of code)
acc:
Code executed if accumulator is = 2)
Carry on:
In the code snippet above, the first line of code is checking to see if the accumulator has the
value of 2 in it. If it is has, then the next instruction is 3 lines away. This is called a conditional
jump and it is making use of relative addressing.
Another example of relative addressing can be seen in the jmp +5 instructions. This is telling the
CPU to effectively avoid the next instruction and go straight to the 'carryon' point.
MUHAMMAD ALI KHAN
PAGE 122
!"#$%&%'($)*)%#+$,$-.*/-%$%0/1+12$
3%$-,#$-4/#5$+*$+.%$6,1+$*'$
%)7',-%$+.%$/#%&/+,7/4/+($*8$
-.,#5%$,#9$,44*:$,$7'/5.+%'$
8;+;'%$+*$;#8*49$7%8*'%$;12$<;-.$
,#$;#-%'+,/#$8;+;'%$),($-,44$8*'$
%&%#$)*'%$;#-%'+,/#$,44/%12$
=/+.%'$:,(>$,$#%:$9,($/1$-*)/#5$
:.%+.%'$:%$4/?%$/+$*'$#*+2$@.%$
A;%1+/*#$/1$:/44$(*;$-*#+'*4$/+>$*'$
:/44$/+$-*#+'*4$(*;BC
PAGE 124
5 System Software
5.1 Operating System
Candidates should be able to: Notes and guidance
Explain why a computer system requires an Operating
System (OS)
Explain the key management tasks carried out by the Including memory management, file management,
Operating System security management, hardware management
(input / output / peripherals), process management
Show understanding of the need for typical utility Including disk formatter, virus checker,
software provided with an Operating System defragmentation software, disk contents analysis/disk
repair software, file compression, back-up software
Show understanding of program libraries Including:
! software under development is often constructed
using existing code from program libraries
! the benefits to the developer of software
constructed using library files, including Dynamic
Link Library (DLL) files
Summary
Batch Processing:
When computing was still a new science, there were not enough machines to satisfy
the demand for processor time from students in universities who wanted great
calculations done, firms who wanted their payroll worked out, and many others. The
big problem was the ‘speed mismatch’ between the user sitting at the keyboard who
was very slow, and the machine which was very fast. This meant that the expensive
part, the computer, was sitting there doing nothing while the human being decided
what to do. There are two simple solutions to this problem, one is to buy more
machines and the other is to make the machines work more effectively by taking
away the slowest part of the system “the human being”. Nowadays we might well
opt to buy more machines, but was too costly in the past. This problem gave rise to
the development of batch processing.
A Batch processing OS is one that does not allow for interaction between the user
and the processor during the execution of the work. Lots of programs or data that
need to be run are collected together (to form a batch) and they are sent to the
computer in one go. The batch operating system then controls their passage through
the computer.
" ! In banks for the production of bank statements from customer files"
! The production of utility bills from customer records"
! Compilation of high level language programs where a number of users want
programs compiled."
Real-time processing:
A real-time O.S. is one which can react quickly enough to a process and get ready
for the next input or process to be carried out.
The following examples of real-time applications show why immediate response can
be vital:
! In a chemical plant the temperature is critical to the result of the process. The
temperature is monitored by a compute that accepts input from a sensor. The
compute uses the sensor data to make decisions about adjusting"
MUHAMMAD ALI KHAN
PAGE 128
Single user
A single user operating system controls a system which has only one user and their
programs at one time. A perfect example of a single user system is the one that you
may have at home. Only one person uses it at a time. Most single user systems are
also multi-tasking.
Multi-user
This type of operating system allows the computer to service more than one user
simultaneously. A multi-user OS has a single (normally powerful) computer which is
connected to a number of terminals. These terminals are not computers, although
they may have a very limited amount of processing power.
The computer sends a message to each of the terminals in turn which is called a
time-share or a round robin system. Each of the small amount of time is called a
“time slice”.
Multi-tasking
The OS can switch between tasks so quickly that it seems to the user as if they are
all being done at once. The tasks are allocated time slices similar to multi-user OS.
Network OS
Disk formatter
When a disk is first produced the surface is blank. It cannot be used to store data
until it has been formatted by disk formatter software. The formatting process divides
the disk into smaller areas, each of which can be searched more easily.
The disk surface is divided into a number of tracks an each track is divided into
smaller blocks called sectors.
The amount of information that can be stored is enormous. One of the tracks is used
as an index to hold data about where the other data are stored. The formatting
process removes all data from the disk so you should save the contents of a disk
elsewhere before re-formatting it.
Virus checker
It is crucial that the virus dictionary is kept up-to-data o a daily basis as new viruses
are constantly appearing.
Defragmenter software
Disk checker software can scan a hard disk to find files or areas that are corrupted
in some way, or were not correctly saved, and eliminate them for a more efficiently
operating hard drive. This is not to be confused with a disk cleaner, which can find
MUHAMMAD ALI KHAN
PAGE 130
Some disk checkers can perform a whole surface to attempt to find any possible bad
sectors, whereas others scan only the contents of the hard disk.
File compression
Files containing video information are usually large in size. File compression software
reduces the size of a file by cutting out much of the duplication of data in the file.
If file is to be sent electronically e.g. a an email attachment, you can use a utility
(such as WinZip) to compress .files may also be compressed to save space on a
secondary storage device.
Backup software
Volumes: Voluming allows the ability to compress and split backup data into
separate parts for storage on smaller, removable media such as CDs. It was
often used because CDs were easy to transport off-site and inexpensive
compared to hard drives or servers. However, the recent increase in hard drive
capacity and decrease in drive cost has made voluming a far less popular
solution
Data compression: Since hard drive space has cost, compressing the data
will reduce the size allowing for less drive space to be used to save money.
Differential and incremental backups: Backup solutions generally support
differential backups and incremental backups in addition to full backups, so
only material that is newer or changed compared to the backed up data is
actually backed up. The effect of these is to increase significantly the speed of
the backup process over slow networks while decreasing space requirements.
Encryption: To prevent data theft, some backup software offers cryptography
features to protect the backup.
MUHAMMAD ALI KHAN
PAGE 131
What is DLL?
A DLL is a library that contains code and data that can be used by more than one
program at the same time. For example, in Windows operating systems, the
Comdlg32 DLL performs common dialog box related functions. Therefore, each
program can use the functionality that is contained in this DLL to implement an Open
dialog box. This helps promote code reuse and efficient memory usage.
Updates are easier to apply to each module without affecting other parts of the
program. For example, you may have a payroll program, and the tax rates change
each year. When these changes are isolated to a DLL, you can apply an update
without needing to build or install the whole program again.
DLL advantages
The following list describes some of the advantages that are provided when a program
uses a DLL:
When multiple programs use the same library of functions, a DLL can reduce the
duplication of code that is loaded on the disk and in physical memory. This can
greatly influence the performance of not just the program that is running in the
foreground, but also other programs that are.
A DLL helps promote developing modular programs. This helps you develop large
programs that require multiple language versions or a program that requires
modular architecture. An example of a modular program is an accounting program
that has many modules that can be dynamically loaded at run time.
When a function within a DLL needs an update or a fix, the deployment and
installation of the DLL does not require the program to be re-linked with the DLL.
Additionally, if multiple programs use the same DLL, the multiple programs will all
benefit from the update or the fix. This issue may more frequently occur when you
use a third-party DLL that is regularly updated or fixed.
MUHAMMAD ALI KHAN
PAGE 132
Assembler
It converts the code written in assembly language into machine language. The
assembly process is relatively simple because assembly language has a one-to-one
relationship with machine code. That is, every assembly language instruction
translates into exactly one machine code instruction.
Basically the assembler translate the mnemonics (e.g. LDA,STO)into binary by having
a simple lookup table with mnemonics in one column and the binary machine code
equivalents alongside.
Compiler
1. The final object (.exe) can easily 1. The final object file can only be
be distributed among many users. produced after all errors in source
2. Once the .exe file is produced, code have been located and fixed.
users do not need the compiler 2. The compilation process uses a lot
software. of computer resources.
3. Users have no sight of the original
source code and so there is no
risk that it could be changed.
MUHAMMAD ALI KHAN
PAGE 133
Interpreter
!"#$"%&&'($)*#+,-%".)%(/),0.)123
!"#$#%&$#%'&()%*$+,$&''-(,%.&(,/&,#01%!+%#2#3/4#5%4"#)%"&6#%4+%7#%3+'*-.#8%+$%
-(4#$*$#4#81%9(%:;<%=-(4#,$&4#8%8#6#.+*'#(4%#(6-$+('#(4>%-0%/0#8%4+%?$-4#%3+8#5%4#04%
@+$%#$$+$0%&(8%4$&(0.&4#%&%*$+,$&'1:;<
9(%-(4#,$&4#8%8#6#.+*'#(4%#(6-$+('#(4%=:;<>%-0%&(%&**.-3&4-+(%/0#8%4+%3$#&4#%
0+@4?&$#1%9(%:;<%3&(%+@4#(%0/**+$4%8-@@#$#(4%.&(,/&,#01
123*)"&6#%&%(/'7#$%+@%8-@@#$#(4%4++.0%&(8%@/(34-+(0%4"&4%&00-04%&%8#6#.+*#$%-(%4"#%
3$#&4-+(%+@%0+@4?&$#1
4#/.)./',#"
!"#%#(6-$+('#(4%?"#$#%4"#%/0#$%3&(%?$-4#%3+8#%-0%3&..#8%4"#%0"#..1%!"#%3+8#%#8-4+$%-0%
&%4#24%#8-4%&$#&%4"&4%&..+?0%8#6#.+*#$0%4+%?$-4#5%#8-4%&(8%0&6#%&%8+3/'#(4%+@%3+8#1%:4%
"&0%@#&4/$#0%4"&4%&00-04%?-4"%4"#%?$-4-(,%&(8%#8-4-(,%+@%3+8#1%!"#0#%-(3./8#A
56,#78#&9:.,'#();#")8#/.)8#&9:.,'#(<=)!"-0%-0%8#0-,(#8%4+%0&6#%4-'#%?"-.#%
?$-4-(,%3+8#1%90%)+/%04&$4%4+%4)*#%4"#%@-$04%*&$4%+@%&%@/(34-+(5%-4%0/,,#040%+$%3+'*.#4#0%
4"#%@/(34-+(%&(8%&()%&$,/'#(40%+$%6&$-&7.#01
B$&3C#4%'&43"-(,1%!"-0%-0%/0#8%@+$%.&(,/&,#0%4"&4%/0#%*&-$0%+@%7$&3C#40%4+%'&$C%+/4%
7.+3C0%+@%3+8#1%:4%&..+?0%4"#%3+8#%4+%7#%$#&8%&(8%/(8#$04++8%'+$#%D/-3C.)1%:@%)+/%
@+$,#4%4+%3.+0#%&%7$&3C#4%?"-.#%?$-4-(,5%3+.+/$#8%0#34-+(0%'&)%"#.*%)+/%4+%8#4#34%
'-00-(,%7$&3C#401
>?(,%@)80.8A*=%!"-0%$#3+,(-0#0%-(3+$$#34%/0#%+@%0)(4&2%&(8%"-,".-,"40%&()%#$$+$01
PAGE 134
Information/data security
IT Security
Confidentiality
Integrity
Remove or disable accounts upon loss of eligibility: Accounts which are no longer
needed must be disabled in a timely fashion using an automated or documented
procedure.
Separate user and administrator accounts: Administrator accounts must not be used
for non-administrative purposes. System administrators must be provisioned with
non-administrator accounts for end-user activities, and a separate administrator
account that is used only for system-administration purposes.
Use unique passwords for administrator accounts: Privileged accounts must use
unique passwords that are not shared among multiple systems. Credentials which
are managed centrally, such as the NetID/password combination, are considered a
single account, regardless of how many systems they provide access to.
Throttle repeated unsuccessful login-attempts: A maximum rate for unsuccessful
login attempts must be enforced. Account lockout is not required, but the rate of
unsuccessful logins must be limited.
Enable session timeout: Sessions must be locked or closed after some reasonable
period.
Enforce least privilege: Non-administrative accounts must be used whenever
possible. User accounts and server processes must be granted the least-possible level
of privilege that allows them to perform their function.
2. Firewall
Systems must be protected by a firewall that allows only those incoming connections
necessary to fulfill the business needs of that system. Client systems which have no
business need to provide network services must deny all incoming connections.
Systems that provide network services must limit access to those services to the
smallest reasonably manageable group of hosts that need to reach them.
MUHAMMAD ALI KHAN
PAGE 140
A firewall is a software program or piece of hardware that helps screen out hackers,
viruses, and worms that try to reach your computer over the Internet.
3.Password Protection
All accounts and resources must be protected by passwords which meet the
following requirements, which must be automatically enforced by the system:
" ! Must be at least eight characters long."
! Must NOT be dictionary or common slang words in any language, or be
" relatively easy to guess."
! Must include at least three of the following four characteristics, in any order:
upper case letters, lower case letters, numbers, and special characters, such
as “! @#$%^&*”."
! Must be changed at least once per year."
4. Digital signature
It is basically a way to ensure that an electronic document (e-mail, spreadsheet, text
file, etc.) is authentic. Authentic means, you know who created the document and
you know that it has not been altered in any way since that person created it.
Digital signatures rely on certain types of encryption to ensure authentication.
Encryption is the process of taking all the data that one computer is sending to
another and encoding it into a form that only the other computer will be able to
decode.
Authentication is the process of verifying that information is coming from a trusted
source. These two processes work hand in hand for digital signatures.
MUHAMMAD ALI KHAN
PAGE 141
Encryption
Encryption involves applying a mathematical function, using a key value, to a
message that can only be read by the sender and the intended receiver. There
are many techniques for this. There are a number of terms used with encryption.
" ! Plain text describes the original unaltered text as created by the sender."
! Encryption algorithm is the calculation which is used to change the plain
text into the encrypted text"
! Cipher text is the message text after the encryption has been performed"
! Decryption is the process of converting the message text back to the"
original pliant text
Symmetric encryption
It is the simplest technique for encryption. The same algorithm and key is used
for both encryption and decryption. The receiver therefore must be in possession
of both the algorithm and the key in order to decrypt the cipher text.
MUHAMMAD ALI KHAN
PAGE 142
Asymmetric encryption
Most modern systems of encryption use the idea of two keys working together,
a public key and a private key.
The public key is universally known and the private key is known only to the
holder.
To use asymmetric encryption, the user must purchase a digital certificate from
a certification authority, such as versign.The certificate contains
" ! The holder’s name"
! An ID number"
! An expiry date"
! The public
" key How it works?"
Suppose Ahmad and Ali each has a digital certificate which gives each their own
public and private keys. So according to rule"
! Ahmad never knows ali’s private key"
! Ali never knows Ahmad’s private key"
MUHAMMAD ALI KHAN
PAGE 143
Data verification
Verification means checking the input data with the original data to make sure
that there have been no transcription errors (transcription means copying the
data)
Verification can be performed in a few ways
1. Entering the data twice: think about you choose a new password, you have
to type it in twice. This lets the computer check if you have typed it exactly
the same both times and not made a mistake. It is not ideal for large
amount of data because a person will take a lot of time entering the data
twice, the person can make the same mistake twice so it wouldn’t get
picked up and you would end up with two copies of the data.
2. Checking the data on screen with the original paper document
3. Printing out a copy of the data and comparing the printout to the original
paper document.
Check Sum: Data will normally be sent from one place to another as a block of
bytes rather than as individual bytes. The computer can add numbers together
without any trouble, so another checking procedure is to add all the bytes together
that are being sent in the block of data. The carry, out of the byte, is not taken
into account, so the answer is an 8 bit number, just like the bytes. This answer is
calculated before the data is sent, and then calculated again when it is received,
and if there are no errors in the transmission, the two answers will match.if,
however the two bytes are different there must be at least one checksum that has
been corrupted and the whole block of data has to be re-sent.
Echoing back
The simplest way of checking the transfer of the data is to send the data back
again. If the data sent back are the same as the data sent in the first place then
the original data must have reached the destination unaltered. If not, the data
must be sent again. This is known as echoing back. This method is very effective,
but suffers from having to send data twice. The transmission mode needs to be
either duplex or half duplex to allow data transfer in both directions.
PAGE 146
Word/phrase Meaning
code of conduct a set of rules governing the behaviour of a
group or organisation (e.g. computer
professionals)
computer ethics moral principles governing the design,
building, implementation and use of computer
systems
copyright the legal right to intellectual property
freeware copyrighted software that is available free of
charge
intellectual property something unique that has been physically
created by someone (an idea that hasn’t been
implemented is not intellectual property)
licence a permit to use/distribute/copy/adapt software
open source software software that can be freely copied, distributed
and adapted
shareware copyrighted software that is available free of
charge for a limited period, after which a
licence must be obtained
MUHAMMAD ALI KHAN
PAGE 150
!"#$%#&'%'$"()*+%
Societies are a collection of individuals, each having their own ideas and beliefs about the type
of behaviour that is acceptable, or not acceptable. These ideas and beliefs can vary widely, and
what one person believes is good and right, another may see as bad and wrong. To make sure
that societies function successfully, they develop principles that define what is morally good and
right behaviour for individuals and the society itself. These principles are known as ethics.
Computer ethics are a set of principles that define what is morally good and right behaviour
when using computers. These ethics cover:
computers’ contribution to the health, safety and welfare of the public
privacy
intellectual property rights (copyright)
censorship.
Computers have an increasingly central role in society, industry, commerce, education, health
and medicine, warfare and government. With so many people using, and being affected by
computers, it is extremely important to have ethics that relate to the design, behaviour and use
of computer systems.
!"!#$%&'(#%)#*%+&,*-#
A code of conduct is a set of rules or practices defining how a group or organisation should
behave – organisations such as businesses, schools, and hospitals have codes of conduct.
Many codes contain rules that seek to protect the organisation from the behaviour of individuals,
as well as protecting the individuals within the organisation. For example, a school’s code of
conduct may include rules about behaviour, dress codes, bullying and respect for others and
their property.
Codes of conduct are also applied to computers and their use. They seek to make sure that
computers are used safely and lawfully, and to protect the interests of organisations and
individuals.
Computer professionals in particular have a need to follow codes of conduct. The computer
systems they design, build, implement and use may have a great impact on, for example, the
success of an organisation, the protection and privacy of its employees, and the protection,
privacy and safety of the public. When designing and building systems, software developers
(engineers) have opportunities to cause harm to their clients and to the public, such as:
failing to make sure their software is fit for purpose (for example, consider the implications of
a safety system that has faulty software)
including malicious software designed to spread malware
including unauthorised and undeclared ways into the system (backdoor) so that they can later
gain access without their client’s knowledge.
In order to prevent these types of behaviour and their consequences, computer codes of conduct are
becoming increasingly important.
MUHAMMAD ALI KHAN
PAGE 151
Developers at Borland included a backdoor in their Interbase database product to make sure
that a client could never be accidentally locked out of their database. This backdoor could be
accessed over the internet. When knowledge of this backdoor became public, Borland were
faced with the possibility that any client’s database could be accessed by an unauthorised user.
From an ethical point of view, Borland originally included the backdoor with the aim of protecting
their clients’ data. After the backdoor was exposed, Borland acted ethically and closed the
backdoor through issuing a software patch.
2.4.4 Network monitoring
In the workplace, computer users might find themselves placed in a situation with conflicting
ethics. For example, the management of a company might suspect that an employee is wasting
work time accessing social networking sites on the company’s computers. This highlights the
importance of having a computer code of conduct in place. If the code of conduct forbids access
to social networking sites via the company’s computers, then the management have an ethical
right to check that the code is being upheld. Without a code, checking on the employee could be
considered an invasion of privacy. However, even with a code of conduct, to behave ethically
the company could only check on those employees for whom they have evidence of unethical
behaviour, as employees’ privacy must still be considered.
2.5 Ownership
When we create something unique, we have ownership of it. The thing that has been created
(which in computing, could be software or hardware, but not simply an idea) is known as
intellectual property. Copyright laws exist to protect our intellectual property. Copyright gives an
individual (or an organisation) the sole and exclusive right to copy intellectual property, sell it,
develop it or license it to others. Copyright makes it illegal for anyone else to duplicate,
replicate, sell or license to others our intellectual property.
Many countries have copyright laws. For example, in the United Kingdom the Copyright,
Designs and Patents Act (1998) protects intellectual property, and the United States of America
has the Copyright Act of 1976.
A lot of intellectual property exists in digital format. Computers make the copying and
distribution of digital property very easy, meaning that unauthorised copies can also be easily
made and distributed. Money made from these illegal copies is essentially theft. Copyright acts
make it illegal to copy and distribute intellectual property without the permission of the copyright
owner, whether via a computer or otherwise.
Many websites offer free downloads of copyrighted music, books, films, television programs,
images and software. This distribution is illegal unless:
the website holds the copyright of whatever is being distributed
the website has the copyright owner’s permission
no copyright exists.
Websites that have copyright permission are given a licence. The licence grants permission for
the copying and distribution of copyrighted material.
2.6 Software licensing
Several types of licence can apply to software:
Commercial – copyrighted software that must be paid for. The copying, distribution and
selling of such software is restricted to those individuals or organisations that hold a licence to
that software.
Freeware – software that is copyrighted but made available free of charge. Keeping hold of
the copyright allows the author to retain control and ownership of the software in case they wish
to charge for it or develop it in the future. The licence does not allow the software to be
modified.
MUHAMMAD ALI KHAN
PAGE 153
Shareware – copyrighted software that is initially given away on a free basis. The software
usually remains free to use for a limited period of time, after which a licence must be obtained.
Software is often made available as shareware to allow users to try it out and to encourage its
distribution. Shareware licences do not allow software to be modified.
Open source software – software that allows anyone to copy, distribute, amend or develop for
their own purposes. Open source software is often developed collaboratively by anyone who
has an interest.
Several bodies exist that promote open source software and freeware:
The Free Software Foundation (FSF) promotes and encourages the right to freely copy,
distribute and modify software. FSF aims to allow users to collaboratively develop software that
is free for anyone to use and adapt. Such software holds the GNU Public Licence that states
that no-one can copyright the software. The FSF also developed GNU, a collection of free
software that users can employ to build an operating system similar to Unix.
The Open Source Initiative promotes open source software. It encourages open source
software to meet certain licence requirements, such as:
free redistribution
the original source code must be supplied alongside any developed work
the original licence must apply to any derived work
the software must be available for anyone to use – no-one must be barred from using it.
A user should always be careful to note the licence that software holds. Failure to so do may lead to
illegal activity and prosecution.
The Association for Computing Machinery (ACM) is the world’s largest educational
and scientific computing society. It has its own Code of Ethics and another set of
ethical principles that were also approved by the IEEE as the standard for teaching
and practicing software engineering.
* Avoid harm to others. Computer systems have an indirect impact on third parties.
They can cause loss of information and resources that might result severely harmful
for users, the general public, or employers. Therefore, software developers should
minimize the risk of harming others due to coding errors, or security issues, by
following standards to design and test systems
MUHAMMAD ALI KHAN
PAGE 154
* Give proper credit for intellectual property. It is mandatory for every software
developer to never use and take credit for someone else’s work, even when it has
not been protected by a copyright law, patent, etc. They must recognize and fully
credit other people’s works, and they should use their own ideas to develop software.
* Respect the privacy of others. Computer systems are wrongly used by some people
to violate the privacy of others. Software developers should write programs that can
protect users’ private information and that can avoid other undesired people to have
unauthorized access to.
* Approve software only if they have a well-founded belief it is safe and meets
specifications. Programmers cannot assume that a system is ready to use only
because it performs the tasks needed. They should make sure these systems are also
safe and meet every specification required by the user. If programs are not safe,
users are unprotected from hackers that could steal important information or money.
Therefore, several tests should be performed in order to ensure a system’s security
before approving it.
* Accept full responsibility for their own work. If a program presents errors, the
software developer should accept full responsibility for his or her work, and
should work on revising, correcting, modifying, and testing it.
* Identify, define, and address ethical, economic, cultural, legal and environmental
issues related to work projects. If a programmer notices and identifies that working
on a project will lead to any kind of problems, then the programmer should report it
to his or her employer before continuing.
MUHAMMAD ALI KHAN
PAGE 155
* Ensure that specifications for software on which they work satisfy the users’
requirements and they have the appropriate approvals. Software developers should
come to their employers to ask for the correspondent approval to the system they
are creating before continuing working on the next part. If it doesn’t meet the
requirements, then a modification to the source code of the system should be made.
* Improve their ability to create safe, reliable, and useful quality software. Since
technology advances faster year by year, and so does virtual criminality, the need of
well-structured and designed programs is increasing. Computer systems get old and
limited by new ones and new devices. Programmers should “further their knowledge
of developments in the analysis, specification, design, development, maintenance,
and testing software and related documents
MUHAMMAD ALI KHAN
PAGE 156
1.7.2 Ownership
What happens when you purchase a specific software application? And if you’ve
purchased software, what is the license agreement for? Do you now own the software
because you paid for it?
Simply put, no. Though you may have paid for the software, what you have actually
done is licensed the application, essentially paying for the rights to use the software
according to guidelines determined by the owner. The owner of the software remains
the person or entity that holds the copyright, giving them the sole legal authority
power to sell, distribute, copy and/or change the content of the software. And unless
the person or organization transfers ownership rights, the rights remain with the
owner no matter how many times the owner legally distributes the software.
When a user either purchases software or freely downloads software from the
Internet, the user is not buying the ownership rights to the software but a license to
use the software according to the licensing agreement, or EULA (for end user
licensing agreement). The EULA is a legal agreement between the two parties and is
legally actionable if either party violates the terms of the agreement. While no two
EULAs are exactly the same.
It’s a good idea to actually read all the way through the licensing agreements of
software you buy or download. One way that spyware has been able to proliferate
over the Internet is by individuals not paying attention to the licensing agreements
that state that along with the intended software the program will also be installing
spyware on your system.
1) Load the software into your computer's temporary memory by running the
program from a floppy disk, hard disk, CD-ROM, or other storage media;
MUHAMMAD ALI KHAN
PAGE 157
2) Copy the software onto other media such as a floppy disk or your computer's
hard disk;
3) Run the program on your computer from a network server on which the
software is resident or stored.
4.1 Quiz
1. Computer ethics are:
a. a set of moral principles that govern the design, building, implementation and use of
computers*
b. a set of legal rules defining how a computer must be used
c. laws defining ownership of intellectual property
Almost all commercial computer software is licensed directly or indirectly from the
copyright owner (the software publisher) for use by the customer through a type of
contract called an "End User License Agreement" (also known as a EULA). Different
products may have different types of EULAs.
The Data Protection Act 1998 controls the way that companies, organizations and
individuals handle personal data.
It states that:
1. Data may only be used for the specific purposes for which it was collected.
2. Data must not be disclosed to other parties without the consent of the
individual whom it is about, unless there is legislation or other overriding
legitimate reason to share the information (for example, the prevention or
detection of crime). It is an offence for Other Parties to obtain this personal
data without authorization.
3. Individuals have a right of access to the information held about them, subject
to certain exceptions (for example, information held for the prevention or
detection of crime).
4. Personal information may be kept for no longer than is necessary and must
be kept up to date.
5. Personal information may not be sent outside the European Economic Area
unless the individual whom it is about has consented or adequate protection is
in place, for example by the use of a prescribed form of contract to govern the
transmission of the data.
6. Subject to some exceptions for organizations that only do very simple
processing, and for domestic use, all entities that process personal information
must register with the Information Commissioner's Office.
7. The departments of a company that are holding personal information are
required to have adequate security measures in place. Those include technical
measures (such as firewalls) and organizational measures (such as staff
training)
8. Subjects have the right to have factually incorrect information corrected
MUHAMMAD ALI KHAN
PAGE 159
The Regulation of Investigatory Powers Act was passed in 2000, and introduces
the power to intercept communications with the aim of taking into account the
growth of the Internet. It regulates the manner in which certain public bodies may
conduct surveillance and access a person's electronic communications
! enables certain public bodies to demand that an ISP provide access
" to a customer's communications in secret;"
! enables mass surveillance of communications in transit;"
! enables certain public bodies to demand ISPs fit equipment to
" facilitate surveillance;"
! enables certain public bodies to demand that someone hand over keys
to protected information;"
! allows certain public bodies to monitor people's internet activities;"
! Prevents the existence of interception warrants and any data collected
with them from being revealed in court."
Free software developers guarantee everyone equal rights to their programs; any
user can study the source code, modify it, and share the program. By contrast,
most software carries fine print that denies users these basic rights, leaving them
susceptible to the whims of its owners and vulnerable to surveillance.
! The FSF provides critical infrastructure and funding for theGNU project, the
foundation of the popular GNU/Linux family of free operating systems and
" the keystone of the Internet."
! Campaigns Team creates educational materials about free software,
convenes the yearly LibrePlanet conference and goes toe to toe against
" powerful interests that threaten computer user rights."
! Licensing & Compliance Lab defends freely licensed software from
proprietary hoarding, advises on licensing issues, and certifies devices that
Respect Your Freedom"
Shareware
Most shareware is delivered free of charge for trial basis e.g. 30 days, but the
author usually requests that you pay a small fee if you like the program and use
it regularly. By sending the small fee, you become registered with the producer
so that you can receive service assistance and updates. You can copy shareware
and pass it along to friends and colleagues, but they too are expected to pay a
fee if they use the product.
Commercial software
Cambridge International AS & A Level Computer Science 9618 syllabus for 2021, 2022 and 2023. Subject content
8.3 Data Definition Language (DDL) and Data Manipulation Language (DML)
Candidates should be able to: Notes and guidance
Show understanding that DBMS carries out all
creation / modification of the database structure using
its Data Definition Language (DDL)
Show understanding that the DBMS carries out all
queries and maintenance of data using its DML
Show understanding that the industry standard for Understand a given SQL script
both DDL and DML is Structured Query Language
(SQL)
Understand given SQL (DDL) commands and be able Create a database (CREATE DATABASE)
to write simple SQL (DDL) commands using a sub-set Create a table definition (CREATE TABLE), including
of commands the creation of attributes with appropriate data types:
! CHARACTER
! VARCHAR(n)
! BOOLEAN
! INTEGER
! REAL
! DATE
! TIME
change a table definition (ALTER TABLE)
add a primary key to a table (PRIMARY KEY (field))
add a foreign key to a table (FOREIGN KEY (field)
REFERENCES Table (Field))
Write an SQL script to query or modify data (DML) Queries including SELECT... FROM, WHERE, ORDER
which are stored in (at most two) database tables BY, GROUP BY, INNER JOIN, SUM, COUNT, AVG
2. flat files contains values at each row and separated with a special symbol so to
reach the data you have to parse each row and obtaining an array of values and
then you can query the data.
3. to control the data in a file , you have to read it line by line and parse it and
because of it they are slow
Relational database
The line between the fields has a ‘1’ on one side and the infinity sign n the other.
This is called a one-to-many relationship.
After creating the relationship, if you open the table city, it will look like similar to
following screen shot. If you click the ‘+’ symbol, it will show the customers in that
particular city.
MUHAMMAD ALI KHAN
PAGE 170
Data dictionary
Data dictionaries do not contain any actual data from the database, only book keeping
information for managing it. Without a data dictionary, however, a database
management system cannot access data from the database.
Data modeling
MUHAMMAD ALI KHAN
PAGE 172
Each database is a collection of related tables; these are also called relations, hence
the name "relational database". Each table is a physical representation of an entity
or object that is in a tabular format consisting of columns and rows. Columns are the
fields of a record or the attributes of an entity. The rows contain the values or data
instances; these are also called records or tuples.
Primary key
Primary key uniquely specifies a tuple within a table. In order for an attribute to be
a good primary key it must not repeat.
Foreign key
A foreign key is a field in a relational table that matches the primary key column of
another table. The foreign key can be used to cross-reference tables. Foreign keys
need not have unique values in the referencing relation.
Candidate key
A candidate key is a column, or set of columns, in a table that can uniquely identify
any database record without referring to any other data. Each table may have one or
more candidate keys, but one candidate key is special, and it is called the primary
key. This is usually the best among the candidate keys. When a key is composed of
more than one column, it is known as a composite key.
Secondary key
A secondary key is made on a field that you would like to be indexed for faster
searches. A table can have more than one secondary key. When database become
large, possibly with hundreds of thousands of records, they can take a while to
search. A database can be set up so that it can be searched more efficiently.
MUHAMMAD ALI KHAN
PAGE 173
Referential integrity
Referential integrity is a property of data which, when satisfied, requires every value
of one attribute (column) of a relation (table) to exist as a value of another attribute
in a different (or the same) relation (table).For referential integrity to hold in a
relational database, any field in a table that is declared a foreign key can contain
either a null value, or only values from a parent table's primary key or a candidate
key. In other words, when a foreign key value is used it must reference a valid,
existing primary key in the parent table
MUHAMMAD ALI KHAN
PAGE 174
Normalization
Edgar F. Codd, the inventor of the relational model, introduced the concept of
normalization and what we now know as the First Normal Form (1NF) in 1970. Codd
went on to define the Second Normal Form (2NF) and Third Normal Form (3NF) in
1971, and Codd and Raymond F. Boyce defined the Boyce-Codd Normal Form (BCNF)
in 1974. Informally, a relational database table is often described as "normalized" if
it is in the Third Normal Form.
An atomic value is a value that cannot be divided. For example, in the table shown
below, the values in the [Color] column in the first row can be divided into "red" and
"green", hence [TABLE PRODUCT] is not in 1NF.
A repeating group means that a table contains two or more columns that are closely
related. For example, a table that records data on a book and its author(s) with the
following columns: [Book ID], [Author 1], [Author 2], [Author 3] is not in 1NF
because [Author 1], [Author 2], and [Author 3] are all repeating the same attribute.
How do we bring an un-normalized table into first normal form? Consider the
following example:
MUHAMMAD ALI KHAN
PAGE 175
To bring this table to first normal form, we split the table into two tables and
now we have the resulting tables:
Now first normal form is satisfied, as the columns on each table all hold just one
value.
nd
2 Normal Form
A database is in second normal form if it satisfies the following conditions:
This table has a composite primary key [Customer ID, Store ID]. The non-key
attribute is [Purchase Location]. In this case, [Purchase Location] only depends on
[Store ID], which is only part of the primary key. Therefore, this table does not satisfy
second normal form.
To bring this table to second normal form, we break the table into two tables, and
now we have the following:
What we have done is to remove the partial functional dependency that we initially
had. Now, in the table [TABLE_STORE], the column [Purchase Location] is fully
dependent on the primary key of that table, which is [Store ID].
In the table able, [Book ID] determines [Genre ID], and [Genre ID] determines
[Genre Type]. Therefore, [Book ID] determines [Genre Type] via [Genre ID] and
MUHAMMAD ALI KHAN
PAGE 177
we have transitive functional dependency, and this structure does not satisfy third
normal form.
To bring this table to third normal form, we split the table into two as follows:
MUHAMMAD ALI KHAN
PAGE 178
File based approach for storage and retrieval of large volume of data Flat files
#" flat files contains values at each row and separated with a special symbol so to
reach the data you have to parse each row and obtaining an array of values and
then you can query the data.
$" to control the data in a file , you have to read it line by line and parse it and
because of it they are slow
Relational database
The line between the fields has a ‘1’ on one side and the infinity sign n the other.
This is called a one-to-many relationship.
After creating the relationship, if you open the table city, it will look like similar to
following screen shot. If you click the ‘+’ symbol, it will show the customers in that
particular city.
MUHAMMAD ALI KHAN
PAGE 181
Data dictionary
Data dictionaries do not contain any actual data from the database, only book
keeping information for managing it. Without a data dictionary, however, a
database management system cannot access data from the database.
Data modeling
Referential integrity
Each database is a collection of related tables; these are also called relations, hence
the name "relational database". Each table is a physical representation of an entity
or object that is in a tabular format consisting of columns and rows. Columns are
the fields of a record or the attributes of an entity. The rows contain the values or
data instances; these are also called records or tuples.
Primary key
Primary key uniquely specifies a tuple within a table. In order for an attribute to be
a good primary key it must not repeat.
Foreign key
A foreign key is a field in a relational table that matches the primary key column of
another table. The foreign key can be used to cross-reference tables. Foreign keys
need not have unique values in the referencing relation.
Candidate key
A candidate key is a column, or set of columns, in a table that can uniquely identify
any database record without referring to any other data. Each table may have one
or more candidate keys, but one candidate key is special, and it is called the
primary key. This is usually the best among the candidate keys. When a key is
composed of more than one column, it is known as a composite key.
Secondary key
A secondary key is made on a field that you would like to be indexed for faster
searches. A table can have more than one secondary key. When database become
large, possibly with hundreds of thousands of records, they can take a while to
search. A database can be set up so that it can be searched more efficiently.
MUHAMMAD ALI KHAN
PAGE 184
Normalization
Edgar F. Codd, the inventor of the relational model, introduced the concept of
normalization and what we now know as the First Normal Form (1NF) in 1970.
Codd went on to define the Second Normal Form (2NF) and Third Normal Form
(3NF) in 1971, and Codd and Raymond F. Boyce defined the Boyce-Codd Normal
Form (BCNF) in 1974. Informally, a relational database table is often described as
"normalized" if it is in the Third Normal Form.
An atomic value is a value that cannot be divided. For example, in the table shown
below, the values in the [Color] column in the first row can be divided into "red"
and "green", hence [TABLE PRODUCT] is not in 1NF.
A repeating group means that a table contains two or more columns that are
closely related. For example, a table that records data on a book and its author(s)
with the following columns: [Book ID], [Author 1], [Author 2], [Author 3] is not in
1NF because [Author 1], [Author 2], and [Author 3] are all repeating the same
attribute.
How do we bring an un-normalized table into first normal form? Consider the
following example:
MUHAMMAD ALI KHAN
PAGE 185
To bring this table to first normal form, we split the table into two tables and
now we have the resulting tables:
Now first normal form is satisfied, as the columns on each table all hold just one
value.
nd
2 Normal Form
A database is in second normal form if it satisfies the following conditions:
This table has a composite primary key [Customer ID, Store ID]. The non-key
attribute is [Purchase Location]. In this case, [Purchase Location] only depends on
[Store ID], which is only part of the primary key. Therefore, this table does not
satisfy second normal form.
To bring this table to second normal form, we break the table into two tables, and
now we have the following:
What we have done is to remove the partial functional dependency that we initially
had. Now, in the table [TABLE_STORE], the column [Purchase Location] is fully
dependent on the primary key of that table, which is [Store ID].
we have transitive functional dependency, and this structure does not satisfy third
normal form.
To bring this table to third normal form, we split the table into two as follows:
MUHAMMAD ALI KHAN
PAGE 188
DDL, which is usually part of a DBMS, is used to define and manage all attributes and properties of a database,
including row layouts, column definitions, key columns, file locations, and storage strategy. DDL statements
are used to build and modify the structure of tables and other objects such as views, triggers, stored procedures,
and so on. For each object, there are usually CREATE, ALTER, and DROP statements (such as, CREATE
TABLE, ALTER TABLE, and DROP TABLE). Most DDL statements take the following form:
CREATE DATABASE
Many database servers allow for the presence of many databases. In order to create a database, a
relatively standard command ‘CREATE DATABASE’ is used.
anything; usually it shouldn’t have spaces (or those spaces) have to be properly
escaped). Some databases allow hyphens, and/or underscores in the name. The name is usually limited in size
(some databases limit the name to 8 characters, others to 32—in other words, it depends on what database you
use).
DROP DATABASE
Just like there is a ‘create database’ there is also a ‘drop database’, which simply removes the database.
Note that it doesn’t ask you for confirmation, and once you remove a database, it is gone forever.
Probably the most common DDL statement is ‘CREATE TABLE’. Intuitively enough, it is used to
create tables. The general format is something along the lines of:
...
);
The ... is where column definitions go. The general format for a column definition is the
PERSONID INT
Which defines a column name PERSONID, of type INT. Column names have to be comma separated, i.e.:
PERSONID INT,
LNAME VARCHAR(20),
DOB DATE,
PRIMARY KEY(PERSONID)
);
The above creates a table named person, with person id, last name, first name, and date of birth. There is also
‘primary key’ definition. A primary key is a column value that uniquely identifies a database record. So
example, we can have two ‘person’ records with the same last name and first name, but with different ids.
Besides for primary key, there are many other flags we can specify for table columns. For example, in the
above example, FNAME is marked as NOT NULL, which means it is not allowed to have NULL values.
Many databases implement various extensions to the basics, and you should read the documentation to
determine what features are present/absent, and how to use them.
MUHAMMAD ALI KHAN
PAGE 190
There is a command to ‘alter’ tables after you create them. This is usually only useful if the table already has
data, and you don’t want to drop it and recreate it (which is generally much simpler). Also, most databases
t ‘alter table’ is allowed to do. For example, Oracle allows you do add a
column, but not remove a column.
ADD <field-name><data-type>
DROP <field-name>
Note that very few databases let you drop a field. The drop command is mostly present to allow for dropping
of constraints (such as indexes, etc.) on the table.
The general syntax to modify a field (change its type, etc.) is:
MODIFY <field-name><new-field-declaration>
Note that you can only do this to a certain extent on most databases. Just as with ‘drop’, this is mostly
useful for working with table constraints (changing ‘not null’ to ‘null’, etc.)
MUHAMMAD ALI KHAN
PAGE 191
1.8 Database and data
DML is used to select, insert, update, or delete data in the objects defined with DDL. All database users can
1.8.3 Data Definition Language (DDL) and Data Manipulation Language (DML)
use these commands during the routine operations on a database. The different DML statements are as
follows:
SELECT statement
INSERT statement
UPDATE statement
DELETE statement
INSERT Statement
To get data into a database, we need to use the ‘insert’ statement. The general syntax is:
INSERT INTO <table-name> (<column1>,<column2>,<column3>,...)
VALUES (<column-value1>,<column-value2>,<column-value3>);
The column names (i.e.: column1, etc.) must correspond to column values (i.e.: column-value1,etc.). There is
a short-hand for the statement:
VALUES (<column-value1>,<column-value2>,<column-value3>);
In which th
‘createtable’ declaration. It must be noted, that this sort of statement should (or rather, must)be
avoided! If someone changes the table, moves columns around in the table declaration, the code using
the shorthand insert statement will fail.
A typical example, of inserting the ‘person’ record we’ve created earlier would be:
Probably the most used statement in all of SQL is the SELECT statement. The select statement as the general
format of:
1.8.3 Data Definition Language (DDL) and Data Manipulation Language (DML)
SELECT <column-list>
FROM <table-list>
WHERE <search-condition>
The column-list indicates what columns you’re interested in (the ones which you want
to appear in the result), the table-list is the list of tables to be used in the query, and
search-condition specifies what criteria you’re looking for.
An example of a short-hand version to retrieve all ‘person’ records we’ve been using:
SELECT * FROM PERSON;
The WHERE clause is used in UPDATE, DELETE, and SELECT statements, and has the same
format in all these cases. It has to be evaluated to either true or false. Table 1 lists some of the common
operators.
= equals to
> greater than
< less than
>= greater than or equal to
<= less than or equal to
<> not equal to
Table 1: SQL Operators
There is also IS, which can be used to check for NULL values, for example:
column-name IS NULL
The update statement is used for changing records. The general syntax is:
1.8.3 Data Definition Language (DDL) and Data Manipulation Language (DML) UPDATE <table-name>
SET <column1> = <value1>, <column2> = <value2>,...
WHERE <criteria>
The criteria is what selects the records for update. The ‘set’ portion indicates which columns
should be updated and to what values. An example of the use would be:
UPDATE PERSON
SET FNAME=’Clark’, LNAME=’Kent’
WHERE FNAME=’Superman’;
DELETE Statement
The ‘delete’ is used to remove elements from the database. The syntax is very
update and select statements:
Basically we select which records we want to delete using the where clause. An example use would be:
AND Clause
!"#$%&'()#
SELECT column1, column2, ...
FROM table_name
WHERE condition1 OR condition2 OR condition3 ...;
*!+#$%&'()#
SELECT column1, column2, ...
FROM table_name
WHERE NOT condition;
,**-"#.!,*#$%&'()#
SELECT column_name(s)
FROM table1
INNER JOIN table2 ON table1.column_name = table2.column_name;
/"!01#23#$%&'()#
SELECT column_name(s)
FROM table_name
WHERE condition
GROUP BY column_name(s)
ORDER BY column_name(s);
!"#$%&'()&*$+,*$-.$/&,)0,$0)1#,#
The following SQL creates a PRIMARY KEY on the "ID" column when the
"Persons" table is created:
!"#$%&
!"#$23&,'45$+,*$-.$/&,)0,$0)1#,#
The following SQL creates a FOREIGN KEY on the "PersonID" column when the
"Orders" table is created:
!"#$%&
In order to design a computer system that performs a specific task, or solves a given problem, the
task or problem has to be rigorously defined and set out, showing what is going to be computed
and how it is going to be computed.
This chapter introduces tools and techniques that can be used to design a software solution to
work with associated computer hardware to form a computer system.
Practice is essential to develop skills in computational thinking. Designs shown with pseudocode
or flowcharts can be traced to check if the proposed solution works, but the best way to actually
test that a computer system works is to code it and use it or, even better, get somebody else to
use it. Therefore, practical programming activities, alongside other activities, will be suggested at
every stage to help reinforce the skills being learnt and develop the skill of programming.
The programming languages to use are:
• Java
• Python
• VB.NET.
Computational thinking skills
Key terms
Abstraction – the process of extracting information that is essential, while ignoring what is not
relevant, for the provision of a solution.
Decomposition – the process of breaking a complex problem into smaller parts.
Pattern recognition – the identification of parts of a problem that are similar and could use the
same solution.
Computational thinking is used to study a problem and formulate an effective solution that can
be provided using a computer. There are several techniques used in computational thinking,
including abstraction, decomposition, algorithms and pattern recognition.
Using abstraction
Abstraction is an essential part of computational thinking. It enables computer scientists to
develop clear models for the solution to complex problems. Abstraction involves extracting
information that is essential while ignoring what is not relevant for the provision of a solution,
only including what is necessary to solve that problem.
Abstraction encourages the development of simplified models that are suited to a specific
purpose by eliminating any unnecessary characteristics from that model. Many everyday items
use abstraction, such as maps, calendars and timetables.
Maps use abstraction to show what is required for a specific purpose, for example, a road map
should only show the necessary detail required to drive from one place to another. The road map
in Figure 9.1 has reduced the complexity by only showing the essential details needed, such as
roads, road numbers and towns, and removing other information about the terrain that would not
be helpful (as shown in the satellite view).
The benefits of eliminating any unnecessary characteristics from the model include
• the time required to develop the program is reduced so the program can be delivered to the
customer more quickly
• the program is smaller in size so takes up less space in memory and download times are
shortened
• customer satisfaction is greater as their requirements are met without any extraneous features.
The first stage of abstraction is to identify the purpose of the model of the situation that is to be
built. The situation could be one that occurs in real life, an imaginary one, or a future event such
as modeling the route of a deep space probe.
Once the purpose has been identified, sources of information need to be identified. These can
include observations, views of potential users, and evidence from other existing models.
The next stage is to use the information gathered from appropriate sources to identify what
details need to be included in the model, how these details should be presented and what details
are extraneous and need to be removed from the model.
For example, maps are used for many different purposes and can take different forms depending
on the identified use. The purpose of the road map model in Figure 9.1 is to allow a driver to
plan a journey, therefore, it includes towns and roads with their numbers. The roads depicted are
a scaled down version of the actual road to help the driver visualise the route.
A rail map model has another purpose and, therefore, looks very different, only showing rail
lines, stations and perhaps details about accessibility for wheelchair users at different stations. A
train passenger has no need to visualise the route, so the rail lines are simplified for clarity.
Using decomposition
Decomposition is also an essential part of computational thinking. It enables computer scientists
to break a complex problem into smaller parts that can be further subdivided into even smaller
parts until each part is easy to examine and understand, and a solution can be developed for it.
When a rigorous decomposition is undertaken, many simple problems are found to be more
complex than at first sight.
Pattern recognition is used to identify those parts that are similar and could use the same
solution. This leads to the development of reusable program code in the form of subroutines,
procedures and functions. When writing a computer program, each final part is defined as a
separate program module that can be written and tested as a separate procedure or function, as
shown in Figure 9.2. Program modules already written and tested can also be identified and
reused, thus saving development time. See Chapter 12 for further details.
Structured English
Pseudocode
ACTIVITY 9A
You have been asked to write an algorithm for drawing regular polygons of any size.
In pairs, divide the problem into smaller parts, identifying those parts that are similar.
Write down your solution as an algorithm in structured English.
Swap your algorithm with another pair.
Test their algorithm by following their instructions to draw a regular polygon. Discuss any
similarities and differences between your solutions.
Flowchart
Figure 9.3
9.2.2 Writing simple algorithms using pseudocode
Each line of pseudocode is usually a single step in an algorithm. The pseudocode used in this
book follows the rules in the Cambridge International AS & A Level Computer Science
Pseudocode Guide for Teachers and is set out using a fixed width font and indentation, where
required, of four spaces, except for THEN, ELSE and CASE clauses that are only indented by
two spaces.
All identifier names used in pseudocode should be meaningful; for example, the name of a
person could be stored in the variable identified by Name. They should also follow some basic
rules: they should only contain the characters A–Z, a–z and 0–9, and should start with a letter.
Pseudocode identifiers are usually considered to be case insensitive, unlike identifiers used in a
programming language.
It is good practice to keep track of any identifiers used in an identifier table, such as Table 9.1.
To assign a value to a variable (the value can be the result of a process or a calculation):
Operators used in pseudocode assignment statements:
ACTIVITY 9B
Identify the values stored in the variables when the assignment statements in the example
above have all been completed. The function ASC returns the ASCII value of a character.
To perform a selection using IF statements for a single choice or a choice and an alternative, and
CASE statements when there are multiple choices or multiple choices and an alternative:
Relational operators used in pseudocode selection statements:
= Equal to
Programming languages may not always have the same selection constructs as pseudocode, so it
is important to be able to write a program that performs the same task as a solution given in
pseudocode.
Here are three programs, one in each of the three prescribed programming languages, to
demonstrate the single choice IF statement. Note the construction of the IF statement, as it is
different from the pseudocode.
While the Cambridge International AS Level syllabus does not require you to be able to write
program code, the ability to do so will increase your understanding, and will be particularly
beneficial if you are studying the full Cambridge International A Level course.
Python
The identifier table for this algorithm is presented in Table 9.2.
This can be used to identify the variables required and complete the identifier table (Table 9.3).
Using these identifiers, each step of the structured English algorithm can be converted to
pseudocode, as demonstrated below.
There are three variables used: MarathonHours, MarathonMinutes and MarathonSeconds. This is
explicitly input and implicitly output as the user needs to understand what input is required. The
pseudocode required is as follows.
2 Calculate and store marathon time in seconds
ACTIVITY 9G
The structured English description has been extended below to check the runner’s time against
their personal best.
IF or CASE
Part of FOR, REPEAT and WHILE
Table 9.4
Flowcharts can be used to identify any variables required and you can then complete an identifier
table. Each flowchart symbol can be used to identify and write one or more pseudocode
statements.
Here is an example of a flowchart of an algorithm that can be used to check an exam grade:
Figure 9.4
The same algorithm is presented in pseudocode on the left. Below is the identifier table:
and form a nested selection (IF) structure, as each following statement is part of
the ELSE clause. It is only at that the selection is complete. The flowchart shows this clearly
and the pseudocode uses indentation to show the nesting.
O OUTPUT 11 Enter your exam mark 11
0 INPUT Mark
0 IF Mark < 40
THEN
Grade +- 11Fail"
ELSE
e IF Mark < 60
THEN
Grade +- 11 Pass"
ELSE
IF Mark < 80
THEN
Grade +- 11 Merit 11
ELSE
0 Grade +- 11 Distinction 11
ENDIF
ENDIF
ENDIF
OUTPUT 11 Your grade is Grade
Q
11 ,
Stepwise refinement
The algorithms looked at so far have been short and simple. When an algorithm is written to
solve a more complex problem, decomposition is used to break the problem down into smaller
and more manageable parts. These parts then need to be written as a series of steps where each
step can be written as a statement in a high-level programming language, this process is called
stepwise refinement.
Many problems are more complex than they seem if a robust solution is to be developed. Look at
the first step of the structured English to calculate a time in seconds.
These steps can now be written in pseudocode. For example, the input routine for the seconds:
10 Data types and structures
In this chapter, you will learn about
• basic data types, and how to select and use them
• two different data structures: records and arrays
• how to handle text files consisting of many lines, using pseudocode
• three different abstract data types (ADTs): stacks, queues and linked lists.
Key terms
Data type – a classification attributed to an item of data, which determines the types of value it
can take and how it can be used.
Identifier – a unique name applied to an item of data.
Record (data type) – a composite data type comprising several related items that may be of
different data types.
Composite data type – a data type constructed using several of the basic data types available
in a particular programming language.
Array – a data structure containing several elements of the same data type.
Index (array) – a numerical indicator of an item of data’s position in an array.
Lower bound – the index of the first element in an array, usually 0 or 1.
Upper bound – the index of the last element in an array.
Linear search – a method of searching in which each element of an array is checked in order.
Bubble sort – a method of sorting data in an array into alphabetical or numerical order by
comparing adjacent items and swapping them if they are in the wrong order.
File – a collection of data stored by a computer program to be used again.
Abstract data type (ADT) – a collection of data and a set of operations on that data.
Stack – a list containing several items operating on the last in, first out (LIFO) principle.
Queue – a list containing several items operating on the first in, first out (FIFO) principle.
Linked list – a list containing several items in which each item in the list points to the next
item in the list.
10.1 Data types and records
Any computer system that is reusable needs to store data in a structured way so that it can be
reused in the future. One of the most powerful tools in computer science is the ability to search
large amounts of data and obtain results very quickly. This chapter introduces data structures that
enable effective and efficient computer-based storage and searching to take place.
For example, the book record data type could be defined like this:
The data type, TbookRecord, is now available for use and an identifier may now be declared in
the usual way:
Items from the record are now available for use and are identified by:
For example:
10.2 Arrays
An array is a data structure containing several elements of the same data type; these elements
can be accessed using the same identifier name. The position of each element in an array is
identified using the array’s index. The index of the first element in an array is the lower bound
and the index of the last element is the upper bound.
The lower bound of an array is usually set as zero or one. Some programming languages can
automatically set the lower bound of an array.
Arrays can be one-dimensional or multi-dimensional. In this chapter, we will look at one-
dimensional (1D) and two-dimensional (2D) arrays.
10.2.1 1D arrays
A 1D array can be referred to as a list. Here is an example of a list with nine elements and a
lower bound of zero.
When a 1D array is declared in pseudocode, the lower bound (LB), upper bound (UB) and data
type are included:
For example:
When a 2D array is declared in pseudocode, the lower bound for rows (LBR) and the upper
bound for rows (UBR), the lower bound for columns (LBC) and the upper bound for columns
(UBC), and data type are included:
For example:
Arrays are used to store multiple data items in a uniformly accessible manner. All the data items
use the same identifier and each data item can be accessed separately by the use of an index. In
this way, lists of items can be stored, searched and put into an order. For example, a list of names
can be ordered alphabetically, or a list of temperatures can be searched to find a particular value.
10.2.3 Using a linear search
To find an item stored in an array, the array needs to be searched. One method of searching is a
linear search. Each element of the array is checked in order, from the lower bound to the upper
bound, until the item is found or the upper bound is reached.
For example, the search algorithm to find if an item is in the populated 1D array myList could be
written in pseudocode as:
This algorithm uses the variables upperBound and lowerBound so that the algorithm is easier to
adapt for different lengths of list. The REPEAT … UNTIL loop makes use of two conditions, so
that the algorithm is more efficient, terminating as soon as the item is found in the list.
As stated in Chapter 9, it is good practice to provide an identifier table to keep track of and
explain the use of each identifier in an algorithm. This allows the programmer to keep track of
the identifiers used and provides a useful summary of identifiers and their uses if the algorithm
requires modification at a later date. Table 10.2 is the identifier table for the linear search
algorithm.
Identifier Description
item The integer to be found
myList Array to be searched
upperBound Upper bound of the array
lowerBound Lower bound of the array
index Pointer to current array element
found Flag to show when item has been found
Table 10.2
Identifier Description
myList Array to be searched
upperBound Upper bound of the array
lowerBound Lower bound of the array
index Pointer to current array element
swap Flag to show when swaps have been made
top Index of last element to compare
temp Temporary storage location during swap
Table 10.3
The following eight tables show the changes to the 1D array myList as the bubble sort is
completed. After each iteration of the FOR … NEXT loop, the highest value in the list is
correctly placed and the lower values of the list are swapped and move towards the start of the
list, until no more swaps are made.
First pass of bubble sort
All nine elements compared and five swaps:
Figure 10.3
Figure 10.5
Figure 10.6
Figure 10.8
Figure 10.10
10.3 Files
Computer programs store data that will be required again in a file. Every file is identified by its
filename. In this chapter, we are going to look at how to use text files. Text files contain a
sequence of characters. Text files can include an end of line character that enables the file to be
read from and written to as lines of characters.
In pseudocode, text files are handled using the following statements.
To open a file before reading from it or writing to it:
Once the file is opened in READ mode, it can be read from a line at a time:
Once the file is opened in WRITE or APPEND mode, it can be written to a line at a time:
This pseudocode shows how the file myText.txt could be written to and read from:
ACTIVITY 10I
Extend this pseudocode to append further lines to the end of myFile. In your chosen
programming language write a short program to complete this file handling routine.
• Stack – a list containing several items operating on the last in, first out (LIFO) principle. Items
can be added to the stack (push) and removed from the stack (pop). The first item added to a
stack is the last item to be removed from the stack.
• Queue – a list containing several items operating on the first in, first out (FIFO) principle.
Items can be added to the queue (enqueue) and removed from the queue (dequeue). The first
item added to a queue is the first item to be removed from the queue.
• Linked list – a list containing several items in which each item in the list points to the next
item in the list. In a linked list a new item is always added to the start of the list.
startPointer
Figure 10.12 Linked list
Stacks, queues and linked lists all make use of pointers to manage their operations. Items stored
in stacks and queues are always added at the end. Linked lists make use of an ordering algorithm
for the items, often ascending or descending.
A stack uses two pointers: a base pointer points to the first item in the stack and a top pointer
points to the last item in the stack. When they are equal there is only one item in the stack.
A queue uses two pointers: a front pointer points to the first item in the queue and a rear pointer
points to the last item in the queue. When they are equal there is only one item in the queue.
A linked list uses a start pointer that points to the first item in the linked list. Every item in a
linked list is stored together with a pointer to the next item. This is called a node. The last item in
a linked list has a null pointer.
10.4.1 Stack operations
The value of the basePointer always remains the same during stack operations:
Figure 10.13
A stack can be implemented using an array and a set of pointers. As an array has a finite size, the
stack may become full and this condition must be allowed for.
In pseudocode, stack operations are handled using the following statements. Please note that you
are not expected to be able to write the pseudocode statements included in this section at
Cambridge AS Level. However, you may find them useful to refer back to if you are studying
the full Cambridge A Level syllabus.
To set up a stack
ACTIVITY 10J
Look at this stack.
Show the stack and the value of topPointer and basePointer when an item has been popped off
the stack and 67 followed by 92 have been pushed onto the stack.
10.4.2 Queue operations
The value of the frontPointer changes after dequeue but the value of the rearPointer changes after
enqueue:
Figure 10.14
A queue can be implemented using an array and a set of pointers. As an array has a finite size,
the queue may become full and this condition must be allowed for. Also, as items are removed
from the front and added to the end of a queue, the position of the queue in the array changes.
Therefore, the queue should be managed as a circular queue to avoid moving the position of the
items in the array every time an item is removed.
When a queue is implemented using an array with a finite number of elements, it is managed as a
circular queue. Both pointers, frontPointer and rearPointer, are updated to point to the first
element in the array (lower bound) after an operation where that pointer was originally pointing
to the last element of the array (upper bound), providing the length of the queue does not exceed
the size of the array.
In pseudocode, queue operations are handled using the following statements.
To set up a queue
Show the circular queue and the value of the length of the queue, frontPointer and rearPointer
when three items have been removed from the queue and 25 followed by 75 have been added
to the queue.
10.4.3 Linked list operations
A linked list can be implemented using two 1D arrays, one for the items in the linked list and
another for the pointers to the next item in the list, and a set of pointers. As an array has a finite
size, the linked list may become full and this condition must be allowed for. Also, as items can
be removed from any position in the linked list, the empty positions in the array must be
managed as an empty linked list, usually called the heap.
The following diagrams demonstrate the operations of linked lists.
The startPointer = –1, as the list has no elements. The heap is set up as a linked list ready for use.
Figure 10.16
The startPointer is set to the element pointed to by the heapPointer where 37 is inserted. The
heapPointer is set to point to the next element in the heap by using the value stored in the
element with the same index in the pointer list. Since this is also the last element in the list the
node pointer for it is reset to –1.
Figure 10.17
The startPointer is changed to the heapPointer and 45 is stored in the element indexed by the
heapPointer. The node pointer for this element is set to the old startPointer. The node pointer for
the heapPointer is reset to point to the next element in the heap by using the value stored in the
element with the same index in the pointer list.
Figure 10.18
Identifier Description
myLinkedList Linked list to be searched
myLinkedListPointers Pointers for linked list
startPointer Start of the linked list
heapStartPointer Start of the heap
index Pointer to current element in the linked list
Table 10.6
The table below shows an empty linked list and its corresponding pointers.
You will not be expected to write pseudocode to implement and use these structures, but you will
need to be able to show how data can be added to and deleted from these ADTs.
ACTIVITY 10L
Look at this linked list.
Show the linked list and the value of startPointer and heapPointer when 37 has been removed
from the linked list and 18 followed by 75 have been added to the linked list.
11.2 Programming constructs
11.2.1 CASE and IF
The algorithm in Example 11.2 uses a nested IF statement, as there are two different choices to
be made. Where there are several different choices to be made, a CASE statement should be used
for clarity.
Figure 11.1 shows that choices can be made using a condition based on
• the value of the identifier being considered, for example < 10
• a range of values that the identifier can take, for example 1:10
• the exact value that the identifier can take, for example 10.
And a final catch all for an identifier that met none of the conditions given OTHERWISE.
For each criterion there can be one or many statements to execute.
Figure 11.1
For example, choices from a menu can be managed by the use of a CASE statement.
Table 11.7 below shows the case statements in VB and Java. Python does not use this construct.
Table 11.7
ACTIVITY 11D
1 Write an algorithm using pseudocode to either add, subtract, multiply or divide two numbers
and output the answer. The two numbers are to be input with appropriate prompts followed
by +, −, * or /. Any other character is to be rejected.
2 Check that your pseudocode algorithm works by writing a short program in your chosen
programming language from your pseudocode statements using the same names for your
identifiers.
11.2.2 Loops
Loops enable sections of code to be repeated as required. They can be constructed in different
ways to meet the requirements of an algorithm.
1 a count-controlled loop FOR … NEXT
2 a post-condition loop REPEAT … UNTIL
3 a pre-condition loop WHILE … DO … ENDWHILE
In order to program efficiently, it is important to select the appropriate loop structure to
efficiently solve the problem. For example, it is better to use a REPEAT … UNTIL loop rather
than a WHILE … DO … ENDWHILE loop for a validation check. The statements inside the
loop must always be executed at least once and there is no need for a second input statement.
For example, to check that a value is between 0 and 10 inclusive.
Table 11.8 below shows post-condition loops in VB and Java. Python only uses pre-condition
loops.
Table 11.8
Table 11.9 below shows pre-condition loops in each of the three programming languages.
VB
Java
Table 11.9
Where the number of repetitions is known, a FOR … NEXT loop is the best choice, as the loop
counter does not have to be managed by the programmer.
1.3 Structured programming
Key terms
Parameter – a variable applied to a procedure or function that allows one to pass in a value for
the procedure to use.
By value – a method of passing a parameter to a procedure in which the value of the variable
cannot be changed by the procedure.
By reference – a method of passing a parameter to a procedure in which the value of the
variable can be changed by the procedure.
Header (procedure or function) – the first statement in the definition of a procedure or
function, which contains its name, any parameters passed to it, and, for a function, the type of
the return value.
Argument – the value passed to a procedure or function.
11.3.1 Procedures
When writing an algorithm, there are often similar tasks to perform that make use of the same
groups of statements. Instead of repeating these statements every time they are required, many
programming languages make use of subroutines or named procedures. A procedure is defined
once and can be called many times within a program.
Different terminology is used by some programming languages. Procedures are
• void functions in Python
• subroutines in VB
• methods in Java.
To be consistent, we will use the term procedure – you will need to check what to do in your
chosen programming language.
A procedure can be defined in pseudocode, as follows:
ACTIVITY 11F
Using the procedure definition and call given for your chosen programming language, write a
short program to define and call a procedure to write a line of stars.
Table 11.10 below shows how to define this procedure in each of the three prescribed
programming languages.
Table 11.10
It is often useful to pass a value to a procedure that can be used to modify the action(s) taken. For
example, to decide how many stars would be output. This is done by passing a parameter when
the procedure is called.
A procedure with parameters can be defined in pseudocode, as follows:
The procedure to print a line with a given number stars would be defined as follows:
The interface between a procedure and a program must match the procedure definition. When a
procedure is defined with parameters, the parameters in the procedure call must match those in
the procedure definition.
Table 11.12 below shows how to define a procedure with a parameter in each of the three
programming languages.
Table 11.12
ACTIVITY 11G
Extend your short program in your chosen programming language to define and use a
procedure that accepts a parameter to write a line with a given number of stars.
There are two methods of passing a parameter to a procedure: by value and by reference. When
a parameter is passed by value, if a variable is used, the value of that variable cannot be changed
within the procedure. When a parameter is passed by reference the value of the variable passed
as the parameter can be changed by the procedure.
A procedure with parameters passed by reference can be defined in pseudocode as follows:
For example, a procedure to convert a temperature from Fahrenheit to Celsius could be defined
as follows:
Table 11.13 below shows how to pass parameters in the three programming languages.
The keyword RETURN is used as one of the statements in a function to specify the value to be
returned. This is usually the last statement in the function definition. There can be more than one
RETURN used in a function if there are different paths through its statements. This technique
needs to be used with great care. For example, a function to find a substring of a given length
starting at a given place in a string that returns a null string rather than an error could be:
Functions are used as part of an expression. The value returned by the function is used in the
expression.
For example, the procedure used previously to convert a temperature from Fahrenheit to Celsius
could be written as a function:
The interface between a function and a program must match the function definition. When a
function is defined with parameters, the parameters in the function call must match those in the
function definition.
Table 11.14 below shows how to write this function in each of the three programming languages.
Table 11.14
ACTIVITY 11I
Re-write the algorithm you wrote in Activity 11H as a function, with a parameter, to convert a
temperature from Celsius to Fahrenheit. Test your algorithm by writing a short program in
your chosen programming language to define and use this function. Note the differences in
your programs and state, with reasons, which is the better structure to use for this algorithm: a
procedure or a function.
When procedures and functions are defined, the first statement in the definition is a header,
which contains
• the name of the procedure or function
• any parameters passed to the procedure or function
• the type of the return value for a function.
When procedures or functions are called, the parameters or arguments (the values passed to the
procedure or function) must be in the same order as the parameters in the declaration header and
each argument must be of the same type as the parameter given in the header. Procedure calls are
single stand-alone statements and function calls form part of an expression on the right-hand
side.
12 Software development
In this chapter, you will learn about
• the purpose, types and stages of the program development lifecycle
• how to document program design using structure charts and state-transition diagrams
• avoiding syntax, logic and run-time errors in programs
• different methods of testing programs to identify and correct such errors
• the types of maintenance used as part of the program development lifecycle.
Program development lifecycle
WHAT YOU SHOULD ALREADY KNOW
You may have studied or heard about the systems (or program) development lifecycle.
Try this activity before you read the first part of this chapter. A program development lifecycle
goes through the same stages for a program.
Name and describe the stages of the program/ systems development lifecycle. There are
different development lifecycles used depending upon the system and the type of program
being developed. Identify at least four of these. Work in small groups to research one of these
and share your findings with the other groups.
Key terms
Program development lifecycle – the process of developing a program set out in five stages:
analysis, design, coding, testing and maintenance.
Analysis – part of the program development lifecycle; a process of investigation, leading to the
specification of what a program is required to do.
Design – part of the program development lifecycle; it uses the program specification from the
analysis stage to show how the program should be developed.
Coding – part of the program development lifecycle; the writing of the program or suite of
programs.
Testing – part of the program development lifecycle; the testing of the program to make sure
that it works under all conditions.
Maintenance – part of the program development lifecycle; the process of making sure that the
program continues to work during use.
Waterfall model – a linear sequential program development cycle, in which each stage is
completed before the next is begun.
Iterative model – a type of program development cycle in which a simple subset of the
requirements is developed, then expanded or enhanced, with the development cycle being
repeated until the full system has been developed.
Rapid application development (RAD) – a type of program development cycle in which
different parts of the requirements are developed in parallel, using prototyping to provide early
user involvement in testing.
12.1.1 The purpose of a program development lifecycle
In order to develop a successful program or suite of programs that is going to be used by others
to perform a specific task or solve a given problem, the development needs to be well ordered
and clearly documented, so that it can be understood and used by other developers.
This chapter introduces the formal stages of software (program) development that are set out in
the program development lifecycle.
A program that has been developed may require alterations at any time in order to deal with new
circumstances or new errors that have been found, so the stages are referred to as a lifecycle as
this continues until the program is no longer used.
12.1.2 Stages in the program development lifecycle
The stages of development in the program development lifecycle are shown in this chapter. The
coding, testing and maintenance stages are looked at in depth and include appropriate tools and
techniques to be used at each stage. Therefore, practical activities will be suggested for these
stages to help reinforce the skills being learnt.
Here is a brief overview of the program development lifecycle, divided into the five stages, as
shown in Figure 12.1.
Analysis
Before any problem can be solved, it needs to be clearly defined and set out so everyone working
on the solution understands what is needed. This is called the requirements specification. The
analysis stage often starts with a feasibility study, followed by investigation and fact finding to
identify exactly what is required from the program.
Design
The program specification from the analysis stage is used to show how the program should be
developed. When the design stage is complete, the programmer should know what is to be done,
all the tasks that need to be completed, how each task is to be performed and how the tasks work
together. This can be formally documented using structure charts, state-transition diagrams and
pseudocode.
Coding
The program or set of programs is written using a suitable programming language.
Testing
The program is run many times with different sets of test data, to test that it does everything it is
supposed to do in the way set out in the program design.
Maintenance
The program is maintained throughout its life, to ensure it continues to work effectively. This
involves dealing with any problems that arise during use, including correcting any errors that
come to light, improving the functionality of the program, or adapting the program to meet new
requirements.
12.1.3 Different development lifecycles
Each program development methodology has its own strength. Different models have been
developed based on the lifecycle for developers to use in practice. The models we will consider
will be divided into the five stages set out above: analysis, design, coding, testing and
maintenance.
In this section of the chapter, we will look at three models: The waterfall model, the iterative
model, and rapid application development (RAD).
This linear sequential development cycle is one of the earliest models used, where each stage is
completed and signed off before the next stage is begun. This model is suitable for smaller
projects with a short timescale, for which the requirements are well known and unlikely to
change.
This development cycle first develops a simple subset of the requirements, then expands or
enhances the model and runs the development cycle again. These program development cycles
are repeated until the full system has been developed. This model is suitable for projects for
which the major requirements are known but some details are likely to change or evolve with
time.
This development cycle develops different parts of the requirements in parallel, using
prototyping to provide early user involvement in testing. Program development cycles are run in
parallel for each part of the requirement, using a number of different teams. Prototyping is often
used to show initial versions to customers to obtain early feedback. This model is suitable for
complicated projects that need developing in a short timeframe to meet the evolving needs of a
business.
Key terms
Structure chart – a modelling tool used to decompose a problem into a set of sub-tasks. It
shows the hierarchy or structure of the different modules and how they connect and interact
with each other.
Finite state machine (FSM) – a mathematical model of a machine that can be in one state of a
fixed set of possible states; one state is changed to another by an external input; this is known
as a transition.
State-transition diagram – a diagram showing the behaviour of a finite state machine (FSM).
State-transition table – a table showing every state of a finite state machine (FSM), each
possible input and the state after the input.
12.2.1 Purpose and use of structure charts
A structure chart is a modelling tool used in program design to decompose a problem into a set
of sub-tasks. The structure chart shows the hierarchy or structure of the different modules and
how they connect and interact with each other. Each module is represented by a box and the
parameters passed to and from the modules are shown by arrows pointing towards the module
receiving the parameter. Each level of the structure chart is a refinement of the level above.
Figure 12.5 shows a structure chart for converting a temperature from Fahrenheit to Celsius. The
top level shows the name for the whole task that is refined into three sub-tasks or modules shown
on the next level.
Figure 12.5 A structure chart for converting a temperature from Fahrenheit to Celsius
ACTIVITY 12A
Draw a structure chart to input the height and width of a right-angled triangle, calculate output
and output the length of the hypotenuse.
Structure charts can also show selection. The temperature conversion task above could be
extended to either convert from Fahrenheit to Celsius or Celsius to Fahrenheit using the diamond
shaped box to show a condition that could be true or false, as shown in Figure 12.6.
Figure 12.6
ACTIVITY 12B
Draw a structure chart to input the radius of a sphere, calculate output and output either the
volume or the surface area.
Structure charts can also show repetition. The temperature conversion task above could be
extended to repeat the conversion until the number 999 is input. The repetition is shown by
adding a labelled semi-circular arrow above the modules to be completed (Figure 12.7).
Figure 12.7
Once a structure chart has been completed, it can be used to derive a pseudocode algorithm.
ACTIVITY 12C
Amend your structure chart to input the radius of a sphere, calculate and output either the
volume or the surface area. The algorithm should repeat until a radius of zero is entered.
Figure 12.8
To derive the pseudo code first, you will need to create an identifier table.
Then declare constants and variables in pseudocode. You can identify two of the variables
required from the parameters shown in the structure diagram.
Provide pseudocode for the modules shown in the structure diagram. As Calculate volume and
Calculate surface area provide the answer to a calculation, these can be defined as functions.
The pseudocode for the whole algorithm, including the selection and repetition, would be as
follows.
ACTIVITY 12D
Draw a structure chart to extend the temperature conversion algorithm to both convert from
Fahrenheit to Celsius and Celsius to Fahrenheit, and repeat until a temperature of 999 is input.
Use your structure chart to create an identifier table and write the pseudocode for this
algorithm.
12.2.2 Purpose and use of state-transition diagrams to
document algorithms
A finite state machine (FSM) is a mathematical model of a machine that can be in one of a
fixed set of possible states. One state is changed to another by an external input, this is called a
transition. A diagram showing the behaviour of an FSM is called a state-transition diagram.
State-transition diagrams show the conditions needed for an event or events that will cause a
transition to occur, and the outputs or actions carried out as the result of that transition.
State-transition diagrams can be constructed as follows:
• States are represented as nodes (circles).
• Transitions are represented as interconnecting arrows.
• Events are represented as labels on the arrows.
• Conditions can be specified in square brackets after the event label.
• The initial state is indicated by an arrow with a black dot.
• A stopped state is indicated by a double circle.
The algorithm for unlocking a door using a three-digit entry code can be represented by a state-
transition diagram. If the door is unlocked with a three-digit entry code, the lock can be in four
states
• locked and waiting for the input of the first digit
• waiting for the input of the second digit
• waiting for the input of the third digit
• unlocked.
If an incorrect digit is input, then the door returns to the locked state. The algorithm halts when
the door is unlocked. A state-transition table shows every state, each possible input and the
state after the input. The state-transition table for a door with the entry code 259 is shown below.
The state-transition diagram for a door with the entry code 259 is shown in Figure 12.9.
Figure 12.9 State-transition diagram for a door with the entry code 259
ACTIVITY 12E
Draw a state-transition diagram for the operation of a television with a single on/off button.
The television can be in three states: on, off and standby. If the button is pressed once (single
press) in standby or off, the television switches on; if the button is pressed once (single press)
when the television is on, the television goes to standby; if the button is pressed twice (double
press) when the television is on, the television goes to off. Double presses in standby or off are
ignored.
Copy and complete the state-transition table and draw the state-transition diagram for the
television operation.
Key terms
Trace table – a table showing the process of dry-running a program with columns showing the
values of each variable as it changes.
Run-time error – an error found in a program when it is executed; the program may halt
unexpectedly.
Test strategy – an overview of the testing required to meet the requirements specified for a
particular program; it shows how and when the program is to be tested.
Test plan – a detailed list showing all the stages of testing and every test that will be
performed for a particular program.
Dry run – a method of testing a program that involves working through a program or module
from a program manually.
Walkthrough – a method of testing a program. A formal version of a dry run using pre-
defined test cases.
Normal test data – test data that should be accepted by a program.
Abnormal test data – test data that should be rejected by a program.
Extreme test data – test data that is on the limit of that accepted by a program.
Boundary test data – test data that is on the limit of that accepted by a program or data that is
just outside the limit of that rejected by a program.
White-box testing – a method of testing a program that tests the structure and logic of every
path through a program module.
Black-box testing – a method of testing a program that tests a module’s inputs and outputs.
Integration testing – a method of testing a program that tests combinations of program
modules that work together.
Stub testing – the use of dummy modules for testing purposes.
Alpha testing – the testing of a completed or nearly completed program in-house by the
development team.
Beta testing – the testing of a completed program by a small group of users before it is
released.
Acceptance testing – the testing of a completed program to prove to the customer that it works
as required.
Corrective maintenance – the correction of any errors that appear during use.
Perfective maintenance – the process of making improvements to the performance of a
program.
Adaptive maintenance – the alteration of a program to perform new tasks.
12.3.1 Ways of avoiding and exposing faults in
programs
Most programs written to perform a real task will contain errors, as programmers are human and
do make mistakes. The aim is to avoid making as many mistakes as possible and then find as
many mistakes as possible before the program goes live. Unfortunately, this does not always
happen and many spectacular failures have occurred. More than one large bank has found that its
customers were locked out of their accounts for some time when new software was installed.
Major airlines have had to cancel flights because of programming errors. One prison service
released prisoners many days earlier than required for about 15 years because of a faulty
program.
Faults in an executable program are frequently faults in the design of the program. Fault
avoidance starts with the provision of a comprehensive and rigorous program specification at the
end of the analysis phase of the program development lifecycle, followed by the use of formal
methods such as structure charts, state-transition diagrams and pseudocode at the design stage.
At the coding stage, the use of programming disciplines such as information hiding,
encapsulation and exception handling, as described in Chapter 20, all help to prevent faults.
Faults or bugs in a program are then exposed at the testing stage. Testing will show the presence
of faults to be corrected, but cannot guarantee that large, complex programs are fault free under
all circumstances. Faults can appear during the lifetime of a program and may be exposed during
live running. The faults are then corrected as part of the maintenance stage of the program
lifecycle.
12.3.2 Location, identification and correction of errors
Syntax errors are errors in the grammar of a source program. In the coding phase of the program
development lifecycle, programs are either compiled or interpreted so they can be executed.
During this operation, the syntax of the program is checked, and errors need to be corrected
before the program can be executed. Figure 12.10 shows an example of a syntax error being
found, and the IDE offering a possible reason for the error.
Figure 12.10
Many IDEs will offer suggestions about what syntax errors are and how to correct them.
Logic errors are errors in the logic of a program, meaning the program does not do what it is
supposed to do. These errors are usually found when the program is being tested. For example,
the program in Figure 12.11 will run, but the results will not be as expected.
Figure 12.11
Many IDEs will allow you to single step through a program to find errors (see Chapter 5, Section
5.2.4). You can also manually work through a program to check that it works as it should, using
tools such as a trace table. Trace tables show the process of dry-running a program with
columns showing the values of each variable as it changes.
Run-time errors happen when the program is executed. The program may halt unexpectedly or
go into an infinite loop and need to be stopped by brute force. If a program is being tested in an
IDE, then this type of error may be managed, and a suitable error message given, as shown
below.
If the program has already been released for use and a run-time error occurs, the developer
should be informed so that the program can be updated and re-released or a patch can be sent out
to all customers to solve the problem. A patch is a small program, released by the developers, to
run with an existing program to correct an error or provide extra functionality. The Windows
operating system is frequently patched and the process of downloading patches and updating the
program has been automated.
12.3.3 Program testing
Programs need to be rigorously tested before they are released. Tests begin from the moment
they are written; they should be documented to show that the program is robust and ready for
general use.
There needs to be a test strategy set out in the analysis stage of the program development
lifecycle showing an overview of the testing required to meet the requirements specified. This
shows how and when the program is to be tested.
In order to clarify what tests need to be performed, a test plan is drawn up showing all the stages
of testing and every test that will be performed. As the testing is carried out, the results of the
tests can be added to the plan showing that the program has met its requirements.
There are several formal methods of testing used to ensure that a program is robust and works to
the standard required. Although there is a testing stage in the program development lifecycle,
testing in some form occurs at every stage, from design to maintenance.
During the program design stage, pseudocode is written. This can be tested using a dry run, in
which the developer works through a program or module from a program manually and
documents the results using a trace table.
For example, a procedure to perform a calculation could be tested as follows.
The errors found in the routine by performing the dry run have been highlighted in red. These
can now be corrected before this routine is coded.
ACTIVITY 12F
Correct the pseudocode and perform the dry run again to ensure that your corrections work.
ACTIVITY 12G
Using the pseudocode algorithm for the volume and surface area of a sphere in Section 12.2.1,
devise some test data and a trace table to test the algorithm.
Swap your test data and trace table with another student then perform the dry run and complete
the trace table.
Discuss any differences or problems you find.
A walkthrough is a formalised version of a dry run using pre-defined test cases. This is where
another member of the development team independently dry runs the pseudocode, or the
developer takes the team members through the dry run process. This is often done as a
demonstration.
During the program development and testing, each module is tested as set out in the test plan.
Test plans are often set out as a table; an example for the calculation procedure is shown below.
The results from this testing show that the error in the subtraction calculation has not been fixed
and the routine is not trapping any abnormal data in the variables used by the calculation. These
errors will need correcting and then the routine will need to be retested.
Several types of test data need to be used during testing:
• Normal test data that is to be accepted by a program and is used to show that the program is
working as expected.
• Abnormal test data that should be rejected by a program as it is unsuitable or could cause
problems.
• Extreme test data that is on the limit of that accepted by a program; for example, when testing
a validation rule such as number >= 12 AND number <= 32 the extreme test data would be 12
at the lower limit and 32 at the upper limit; both these values should be accepted.
• Boundary test data that is on the limit of that accepted by a program or data that is just
outside the limit of that rejected by a program; for example, when testing a validation rule such
as number >= 12 AND number <= 32 the boundary test data would be 12 and 11 at the lower
limit and 32 and 33 at the upper limit; 12 and 32 should be accepted, 11 and 33 should be
rejected.
ACTIVITY 12H
An algorithm is to be written to test whether a password is eight characters or more and 15
characters or less in length. The password must contain at least one digit, at least one capital
letter and no characters other than letters or digits.
Devise a set of test data to be used to test the password checking algorithm.
Discuss any problems there may be in devising a complete set of test data.
As the program is being developed the following types of testing are used:
• White-box testing is the detailed testing of how each procedure works. This involves testing
the structure and logic of every path through a program module.
• Black-box testing tests a module’s inputs and outputs.
• Integration testing is the testing of any separately written modules to ensure that they work
together, during the testing phase of the program development lifecycle. If any of the modules
have not been written yet, this can include stub testing, which makes use of dummy modules
for testing purposes.
When the program has been completed, it is tested as a whole:
• Alpha testing is used first. The completed, or nearly completed, program is tested in-house by
the development team.
• Beta testing is then used. The completed program is tested by a small group of users before it
is generally released.
• Acceptance testing is then used for the completed program to prove to the customer that it
works as required in the environment in which it will be used.
12.3.4 Program maintenance
Program maintenance is not like maintaining a piece of equipment by replacing worn out parts.
Programs do not wear out, but they might not work correctly in unforeseen circumstances. Logic
or run-time errors that require correction may occur from time to time, or users may want to use
the program in a different way.
Program maintenance can usually be divided into three categories:
• Corrective maintenance is used to correct any errors that appear during use, for example
trapping a run-time error that had been missed during testing.
• Perfective maintenance is used to improve the performance of a program during its use, for
example improving the speed of response.
• Adaptive maintenance is used to alter a program so it can perform any new tasks required by
the customer, for example working with voice commands as well as keyboard entry.
ACTIVITY 12I
Analyse the pseudocode algorithm for the volume and surface area of the sphere in Section
12.2.1 and identify at least three improvements you could make to the functionality of this
algorithm.
ACTIVITY 12J
1 Explain, using examples, the difference between syntax and logic errors.
2 A programmer wants to test that a range check for values over 10 and under 100 works.
Identify three types of test data that should be used. Provide an example of each type of test
data and describe how the program should react to the data.
3 Identify three types of program maintenance and describe the role of each type of
maintenance.