0% found this document useful (0 votes)
280 views20 pages

A Level Computer Science P3 Sample

Uploaded by

Hajmola
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
280 views20 pages

A Level Computer Science P3 Sample

Uploaded by

Hajmola
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
‘Article No, 257 9618 COMPUTER SCIENCE PAPER-3 Editorial Board: Topical Workbook Raahim Ahmed Updated Till- 2023 GreenHal,LACAS, The ety school, Kims Fazol e Malik a ementel, GAC Navid Saqib Questions order new to old Tee esa ae: Lana, 196. — Mark schemes included ROOTS, Sci = AllVariants M. Zeeshan Shafiq GreeaHall, BSS, LGS, The City Sctoo, American Lycaum, Areca Lott ‘Sameer Raza Groontal, LS Farooq Mushtaq, GreonHal, UCL READ &WRITE PUBLICATIONS Lahore Sale Point: Shop No, 38, Uru Baza Lahore. Pr ox237200%00. Karachi Sale Point Shop Nc, Imperiaeo, Faken on, azar. at Webs wa seasnwte.og E-Books wwovrmaboakscon Emma eodancwreticegymalicom Alright reered. No part of his publication may be reproduced ore narra este or transite, inany fom or by any means, electron, meckanical, photcopring recording oor mithou! he prior rites prmicnn ofthe Pls Tie Publited by Printed by ‘Composed Deparment ‘Graphics beparnent “Legal Advisor Serie: ion Prcocearieteo eetstarae Read & Wet Poblictions. Read & Wit Pbliations. ‘Share! Kha, Sozman Baksh, Sbasb, Wags, M. Anas, ‘Kl, Sam, M. Ss Sbahmeer, Adee Share! Kban Mita Taig Ahmad (Advocte Supreme Coat) Room No, 10, 1,12 AL-Msjeed Centre 1-Mozang Read, Lahore ‘Te 04237236445, Fax 002.97281367 one2on4odars 2004 DISTRIBUTORS Sete ere iste See eas ener eo rr aSRe ead an Wee Pablo CONTENTS [UNIT 73 [ Bata Representation 3 18:1 | Userdofined data ype 6 ‘Answer Section 22 73a _| Fle organisation and access 28 ‘Answer Section 4 73: _| loaing-point number, representation and manipulation 38 ‘Answer Section 0 INIT 14 | Communication and internet Technologies ———————— |_71 "4:4 Protocos 72 ‘Answer Section m 742 _[Cirout swichng, packet switching 4 ‘Answer Section 00) (ONFT75 | Hardware and Virtual Machines. 107, 16:1_| Processors, parallel processing and vitual machines. 108; “Answer Section 2 72 _| Boolean algebra and ogi cous 134 “Answer Section 475 (ONT 76 | System Sonware 201 16:1 | Purposes of an operating systom (OS) 202, ‘Answer Section 212, 762_| Translation software 27 “Answer Section 258) lon a7 [Security 277 17.4_[ Encryption, encryption protocol and digital corieates 218. ‘Answer Section 22 (UNIT 18 [Artificial Inteligence 303, ‘Answer Section 309) INIT 19 | Computational Thinking and Problem Solving 315; 19:4 _[ Agortims 316; ‘Answer Section 326 782__[ Recursion 330 ‘Answer Section 33 (GNIT20_| Further Programming 30 "20:1 | Programming paradigms ~ [384 ‘Ans wor Section 349) 20:2 _| Fle processing and excopton handing 356 “Answer Section 350 esa wa wie umeatons BLANK PAGE 5 Unit 13 DATA REPRESENTATION Computer Science P-3 ‘Syllabus Topical Workbook 13.1 User-defined data type Article Number: 257 13.2 File organization and access 13.3 Floating-point numbers, representation and Editorial Board salamat READ WRITE PUBLICATIONS capa ge es net Terai Pt, Sip npn enn eater oat Cab ee eee ESTE pnts porecmcmnengeacn rte Papers. $82 “Download App Now ‘Corp Sane At? Top Weedock 124: dep Unit 13: Data Representation 13.1: User-defined Data Type 4. Mid 231P32106/a (@) Write pseudocode statements to dectare the composite datatype, TArpointments, te hold data about patients fora dental clinic. It wil include for each patient + name (list name and last name) + date of birth telephone number + date of last appointment + date of next appointment + alltreatments are complete (yes oro). oy 2. Miu 231P31/04, Mid 23/33/04 Two descriptions of user-defined data types are given. Give appropriate type declaration statements fr each, including appropriate names. (@) data type to hold a set of prime numbers below 20. These prime numbers are: 2,3,5, 7,1, 13,17, 19 (©) data typa ta point to a day in the week, for example Monday. 3. OIN 22132106 ‘A program to manage regular fight details at an airport requires some user-defined data types. (@) Wate pseudocode statoments to dectare the enumerated data type Aircraft to hold data _ahout the typas of aireratt used fora ight ‘These types of aircrat are: C300, C350, D242, E787, X380. a "Light to hold data about (©) Wiite pseudocode statements to declare the composite data type fights to a speci: destination. These include: + ght number, which could be any combination of eters and numbers + destination + date of departure + type of aircraft used. conor Scene Alot P. Tepe Wetock 1 124; Urer aed dn be eat end ie Pasetone see Use the enumerated data type you created in part (a). : tate a Xe) Wao the pseudocode statement to set up a variable for one record of the composite data type Flight. oy arpa 6 ta ra og wan oot wn part (c)(i). Fe oe eon canbe atc doparire | rarnoca fapecforzot ea [ a0 Use the fied names you created in part (b). 4, ON 221P31/03, ON 221P33/03 {8} State what is meant by the term enumerated data type. {Site what is meant by the term pointer datatype. 7 . a Po m (e) The months of the year are: January, February, March, Apri, May, June, Juy, August, ‘September, October, November and December. Wills Ure poeudocode statement to define the datatype Quarter’. to hald the names of the fist three months of a year. ‘Computer Senos Alva. Tope etek 1 Laer ded ata pe (q) The composite data type Pet Is used to store data about the various pets of @ group of students I uses these fields: id name Data type Pettiane String Bnimaltype Siring Petage Integer PetGender (Char Owneriane String (White the pseudocode statement to set up a variable for ane racard of tha composi. ata type Pet, : ae " (i) Write pseudocode to store the detalls ofthe following pet, n the varable you set up in part (2) Pettiane | Aninaltype | PetAge | PetGender | Ovnerllane Fibbies cae 2 ™ wesnine Smich 8 ‘5. OIN 21/P32/Q3, OIN 21/P31/03 (9618) Enumerated and pointer are two non-composite data types. (a) Write pseudocode to create an enumerated type called Parts to include these parts sold In a computer shop: Monitor, CPU, SSD, HDD, LaserPrinter, Keyboard, House Fs f ae : von (2) (b) Wite pseudocode to create a pointer type called SelectParts that will reference the ‘memory location in which the current part name is stored, 6. IN 21/P32/011/a,b (9608) Data types can be defined using nseudocode. ‘The data type, BicycleRecord, is defined in pseudocode as: Comper Secs All 8 Tepe Woxbook 2 +1 Unease ea sod me ed and Wie Paes ud ‘TYPE BicyeleRecord DECLARE BicyclezD + INTEGER: DECLARE BicycleAvailable : BOOLEAN DECLARE Bicycletocation : (RiverSide, BusStation, Trainstation, Townsquare, Library) DECLARE DateChecked DATE ENDTYPE Avatiable, LoanBicycle, Is declared in pseudocode as: DECLARE LoenBicycle 1 BicycieRecora (@) Wite pseudocode statements to assign 567 to the Bicyclero of LoanBicycle and FALSE 0 he BicycleAvai lable of LeanBicycle. (0) The type definition for BicycieRecora is changed. (0) The definiton has been extended to include borower identification numbers, BorrowerTD, for the last 10 people who borrowed a bicycle, Eech identification number isan integer. Write the pseudocode statement needed in the type definition of SicycieRecord, 7 7 roo {f] (ii) The values forthe field 8icycie7D must be between S00 and £99 Inclusive, Rewrite one pseudocode ine from the type definition of BicycleRecord to implement the change. io 7. OIN 211P31/01/a,b, O1N 21/P33/0/a,b (9608) Data types can be defined using pseudocode. “The data type, Computer Record, is defined by the following pseudocode: TYPE ComputerRecord DECLARE ComputerrD INTEGER DECLARE Computertype +: (Laptop, Desktop, Tablet) DECLARE ConputerLocation : (Labl, Lab2, Lab3, Mobile) DECLARE DateTested are ENDEYEE Avatiable, schooConputer, is decared in pseudocode 2: RIE AD & WRITE. DECLARE SchoolConputer : ComputerRecord PUBLICATIONS. @ wwwreadnwrite.org Corr Senos Ave. Tepe ebook 181: Uueedeod cla pe (2) Write peoudocede statements to assign 1224 to the Conpterth of Schon? tonputar and Lab2 to the ConputerLocat ion of SchoolComputer, (&) ‘The type definition for Conputersecorais changed, i) The definition has been extended to irclude the student identifcation numbers, student 10, for up to 20 students who can use that computer. Each student identification ‘number isan integer. \Write the extra line of pseudacede neededin the type definition for ConputerRecord. iO} (i) The values forthe fielé Computer must be between 1000 and 1998 inclusive. Rewrite one pseudocode line from the typedefintion of conputerRecora to implement the change. t 3. MIJ 21/P32/Q2, M/J 21/P31/02, Wis 21733102 (9618) {@) Describe the purpose of @ user-defined data ype. (6) Define, using pseudocode, the following enumerated datatypes: {) School bay to hold data about the days students are usually in school z : nm CO) school days. ny) eens : Soares READSWRITE © one on a schoo! day PUBLICATIONS © one not on a school day. @ Www.readnwrite.org Lect! perro 4 Contr Seance Ale! P. Tepe Weston ax ‘a: Aner Secon aad nds Psestons 4, ON 221P31/011, OIN 22/P33/011 ® } (One mark for each correct OOP term definition + Instance ~ an occurrence of an object a specific object based ‘onthe case an instantiation of a class. ‘+ Inheritance — the capably of defining a new class of objects that has all the attributes and methods from a parent class. ‘+ Polymorphism ~ allows the same method to take on different ‘behaviours depending on which class is instantiated ‘methods can be redefined for derived classes. 8 ‘One mark for each point: © Car and ENDCLASS Four declarations ~ must use the Identifers used inthe assignments Constructor header ~ must use CarBodyType ‘Two assignments - must use Carvake Constructor identifier forthe car model and the dentifer inthe Model assignment statement match cuASs car PRIVATE Make : STRING PRIVATE Model : STRING PRIVATE Bodytype : STRING PRIVATE Fuel? STRING PRIVATE NunberBuilt : INTEGER PUBLIC PROCEDURE NEW (CaxMake : STRING, Carliodel ; STRING, CazBodyType : STRING) Make « CaxMake Model « CazModel, Bodytype « CarBodyType Poel ©" NunberBuilt © 0 [ENDPROCEDURE, getFuel getNunbersuilt () ENDCLASS. (s} 5. Mid 221P32101/6 @) () PRIVATE OwnerName : STRING fo) {l) To ensure that attributes can only be accessed by the class's own methods ‘To enforce encapsulation // ensure they are hidden a 6. Mid 221P32/02 ® () ©) tutors (nina, sam). 2) freya, hua Il hua, freya a aie Reece READS WRITE a eo ee on Oe PUBLICATIONS ee atk care @ www.readnwriteorg ‘tutors(R, X) 4 Compt Seca eden Wate 6 2 mat hewn ein 7. MY 2131/02, Mid 27P33102 (a) type (cazacal, wild). hair (caracal, short) @ (@ persian it] (4 @ expe(ter, domestic). m1 (i) spots teiaspotty, yes) reypelwilaspocty, wild). a 8, mig 22/31/07, Mid 22/P33/07 (8) 1 mark per point Acrylic has attibule So¢t of type BOOLEAN Yioo! has attibute iiool Type with suitable datatype Acrylic and Wool have method Yarnzn£o () Acrylic, Wool and 1x at least one inherit (one artow correct) from Yarn Rerylic, oo! and six all inher (all arows correct from Yarn constructor () | Extenomersanie | derylte wot ae aaa wooitype: S2AinG | Percentages INTDSER f———_ [eaneersceorny | constructor constsuctort) | | Yerntafott Yaratntou vaminto() (0) Properties max 2 the data toms /atibutes tho datatypes characteristics defined ina class Methods max 2: +e procede untons/rogramied narucona ing se super case base clase «SFimplemendng the behaviours READ X WRITE < _"atatact onthe properties /tibutes PUBLICATIONS inneriance max: @www.readnwrite.org ‘+ Mathods and properties /atibutes contined in one cats super dass /base class + Are made available to / reused by another classi derived class ) ‘camps Seance hlew Tea! Wotbook 2: Anon secon ead ene Pubes. ‘9. Mid 221P31/09, mld 221P33/09 {a} 10m #500: Immediate 500 DD 500: Direct 100 uDI_500: Indirect 20 3 o Instruction Label | Opeode | Operand zou] #20 ui |¥ ‘apo | twenty ‘Deenty: #20 ‘One mark for Lp #20 seen ‘One mark for string 20 at any address ‘One mark for labeling that address e.g. Twenty away ftom the program code (One mark for labeling addresses away from the program code as ¥ and z ‘One mark for correct use of LOT ¥ ‘One mark for correct use of STO z ‘One mark for correct use of ADD with labelled address mi “40, co 24/32/02, O1N 21/P31/02 (9618) ‘One mark for each single correc ine from Programming Paradigm to Description Programming Paradigm Description Programs using the instetion set ofa Programe based on events such 8 Programs using the concopts of class, Innertance, encapsulation and polvmarphism Programs wih an explist sequence of ‘commands tat update the program state, wih or without procedure cals Programs tht specity the desired Teal rather than now to gti ro) Conger Scenes Alon. Tp! Wetbook ‘AL: Anaee Seion 11. Mid 21732199, MJ 211°31/09, M/S 211P33/08 (9618) (2) One mark for each correct marking point (Max 2) + Imperative languages use variables which are changed using (assignment) statements + “they rly on a method of repetition / iteration. : sequence of commands for the computer to inthe order written / given each line of code changes something in the program run. pl {b) One mark for each correct marking point (Max 2) ‘+ Inszucts a program on what needs to be done instead of how to doit ‘+ s-using facts and rules ‘using queries to satisfy goals. ‘+ Can be logical or functional ‘+ Logical states a program as a set of logical relations ‘+ Functional — constructed by applying functions to arguments / uses a mathematical syle RI (6) One mark for each correct programming paradigm (Max 4) Program code example Programming paradigm ‘male (John). femate (ethel) Declarative parent (john, ethe) FOR Counter = 1 10 20 X= X * Counter Procedural imperative Ext counter Start: LDD Counter Nc acc Lowtevel / assembly public class Vehicle ¢ Frivate speed; oe Object oriented / (OP) apeed = 0; 4 12, Mid 24/P31/07/d, Mid 21/P33/Q7Id (9608) (@) (0) One mark per point ‘Load the accumulator with status of heaters and air conditioning units 1 Load the accumulator withthe contents of address 300 / ‘+ Mask out the bits for container 1 Mask out 4th and Bthbit ‘+ See whether both heater is on and the airconditioning is on 1. Compare the contents ofthe accumulatoriprevious result with 1219001000 (888) Conn Sos Ale P. Tope Wordook onc ane Wie Pabst 24 Arua Seon ‘+ IF the heaters on and the alr conditioning ison / jump to ERROR routine jump te ERROR routine If bit pattems are equal 4 (One mark keeping instructions 1 and 4 the same oF ark AND 32 One mark cx? £22 upp 300, AND &11 // AND B00010002 ene 11 // CMP 800010002 ‘SPE ERROR 43, OIN 20/P32V08/6 (@) (1 mark per bullet point ‘+ Storing 0in 602 and 602 ‘+ Loading the correct pattern for 603 + Storing in 603, pm 90 /#0 / 300000000 STO €02 S10 €02 pM 300002221 /#25 /40F 70 603 iy 602 / 42 / Booodo020 oa 7 #4 / BO0000300 TEM (CHECKPLAGS 14, OIN 20/P31/QIc, ON 20/P33/07!6 (@) (Loading 0 and storing in 801 and 802 Loading 240 “and storing in 003 ‘uom #0/800000000/ (0) 0 ‘STO a0 S70 802 pm #240/811310000/6F0 10 80 (i &40 / #66 / Bor000000 20 / 432 / Boolo0000 TEMP (CHECKLORD a 4 8 4) READS WRITE Be EHEGRI a compte Seance Aled. Tcl Wc {202 Fe prcesng ad eaptontanng a ead an We Publetons 20.2: File Processing and Exception Handling 4. MiN23 P3218 (8) This pseud2oode algorithm reads dental records stored in arandom file using the user-defined data type Tappointments and prints the contents ofthe fle, one record ata time. ‘Complete tis file handing pseudocode: DECLARE DentalRecord : ARRAY[1:250] OF TAppointments DECLARE Dentalfile : STRING DECLARE Count : INTEGER DentalFsie « "bentairaie.cac” OUTPUT “Ihe file", DentaiFile, " contains these records: OPENETLE REPEAT SEEK DentalFile, Count oureuT Dentaiecoraicount) Count count + 1 v(Dental File) 2 Mid23 P3t/at0, Mid 23 P33/Q10 7 “The pseudocode algorithm shown copies an active accounts text fle Activer'ite-ext to an archive accounts text fle hrcnsveFite. txt, one ine at a time. Ary blank lines found in the ‘active accounts text file are replaced with the words "Account not present in the archive ‘accounts text fe. ‘Complete ths fle-handing pseudocode. DECLARE Recount = SURING ‘OPENFILE “Archiverile.txt" FOR WRITE WHILE WOT een ss READPILE "ActiveFiie.txt™, Account IF Account = "THEN WRITEFILE “ArchiveFile.txt", WRITEETLE “ArchiveFile.txt”, ENDIF (CLOCEPILE "Archiverile.txt" ‘Corp Scene Alen P. Tope Wertook os 202.Fm procemng wa enayon tanding : ead andre Pbsctone Mis 22 P32109 State the reasons for incluging exception handling routines when wring @ program. Include an example of an excaption in your answer. ‘o1m 21/Psziatie (9608) Data types can be defined using pseudocode. “The data type, BicycLeRacord, is defined in pseudocode as: ‘TYPE BicycleRecord DECLARE BicyclezD INTEGER DECLARE BicycleAvailable : BOOLEAN (Riverside, BusStation, Trainstation, DECLARE BicycleLocation ‘TownSquare, Library) DECLARE DateChecked DATE ENDTYPE, variable, LoanBcycle, Is dectared in pseudocode as: DECLARE LoanBicycie : BicycleRecord {@) Data about all the bieycles are stored ina file that uses random file organisation. Bicycle is used asthe key fied. Explain how a program could add an extra record to this Me, ‘ON 24 P31/Q11/6, OIN 21 P33/QAle Datatypes can be defined using pseudocode. “The data type, Computer Recor, is defined by the following pseudocode: TYPE ComputerRacord READ & WRITE PUBLICATIONS DECLARE ComputeriD 1 INTEGER @uwwreadnwrite org DECLARE ConputerType (oeptop, Desktop, Tablet) DECLARE ConputerLocation : (Labl, Lab2, Lab3, Mobile) Compr ence Ale 2 ep och 20.2 erent ecto arr Peden Wie Palen DECLARE DateTested : ENDryeE, ‘Avatiable, schoo Computer, Is declared in pseudocode as: DECLARE SchoolConputer : Conputerzecord {2} Data about all the computers are stored in a fle that uses random fle organisation. Computer0 is used as the key fel Explain how a program could search fora record stored in this fle, a READS WRITE PUBLICATIONS @ www.readnwriteorg os 4. Compe cance Aleve. Tepe Wabook 202 Anwar Secon ad end Wr Puonena PeEMeaercn Ws 23 P32/06/> {a} Gne mark for each correctly completed line (Max 5) DECLARE DentalRecord : ARRAY[1:250] OF TAppointwents DECLARE DentalFile : STRING DECLARE Count : INTEGER DentalFile « “DentalFile.dat" OUTPUT “The file ", DentaiFile, " contains these records: (OPENFILE DentalFile FOR RANDOM count <1 REPEAT SEEK DentalFiie, Count GETRECORD DentalFile, DentalRecord[Count) OUTPUT DentaiRecord{Count) Count « count +1 UNTIL EOF (DentaiFile) CLOSEFILE DentaiFile 8 Wis 23 P31/010, MiJ 23 P33/Q10 ‘ne mark for each correctly completed tine (Max 5) DECLARE Account : STRING OPENFILE "ActiveFile. txt" FOR READ OPENFILE "ArchivePile.txt" FOR WRITE WRILE NOT EOF ("Active ile. txt’ READPILE "ActiveFile.txt", Account WRITEPILE "ArchiveFile.txt", Mecount not present” ELSE ‘WRITEFILE "ArchivePile.txt™, Account ENDIF BNDWTLE CLOSEELLE “Activeriie. exe" CLOSEFILE "ArchiveFila. txt" fo) is 22 P32/09 "To trap (Some) runtime errors To prevent a program halting unexpectedly ‘To produce meaningful error messages for these errors Example dvide by 2070 I! end of ile fle not found BI ‘IN 211P32/a1/¢ (9608) (@) Any three from ‘© Bicycle ID hashed to give address / home location Check if record already stored at address / home location nothing stored, store new record I another record already stored search overflow area / next record Until free space found or whole area searched {no space output error message ro] ‘Corpse Sree Aneto Wrkok 20 202 Annet Seaton 5. OIN 21/P31/Q1/c, OIN 24/P33/@1/c (9608) (@)_ Any three trom ‘Computer 1D hashed to give address / home location ‘Compared to ID stored at address / home location Nothing stored, output message record not found’ Record IDs equal, record is found Record IDs not equal, search overfiow area / next record ntl record found or whole area searched no record found error massage 8) READ & WRITE PUBLICATIONS @ www.readnwriteorg

You might also like