Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Computer Science (A Level) A23cmp Assessment #4 Duration: 60 minutes Student Number: Teacher: INSTRUCTIONS • Use black ink. HB pencil may be used for graphs and diagrams only. • Answer all the questions. • Read each question carefully. Make sure you know what you have to do before starting your answer. • Where space is provided below the question, please write your answer there. • You may use additional paper, or a specific Answer sheet if one is provided, but you must clearly show your candidate number, centre number and question number(s). INFORMATION FOR CANDIDATES • The total number of marks for this paper is 60. • The number of marks is given in brackets [ ] at the end of each question or part question. • Quality of extended repsonses will be assessed in questions marked was an asterisk (*). Question 1 2 3 4 5 6 7 8 9 10 11 12 Total Mark © OCR 2022. You may photocopy this page. /3 /2 /3 /6 /9 /2 /11 /2 /3 /5 /3 /11 /60 Page 1 of 20 Created in ExamBuilder 1. Operating systems make use of device drivers. Define what is meant by the term ‘device driver’, giving one example of a device driver that a home user would need. Definition Example [3] 2. Julie is a university student. She is considering buying a laptop to help with her studies both at home and university. Her friend has told her she will need to choose an operating system to run on her laptop. The operating system Julie is considering makes use of paging to manage the laptop’s memory. Explain one benefit of using paging for this purpose. [2] 3. A cinema offers discounted tickets, but only under one of the following conditions: • • Customer is under 18 and has a student card. Customer is over 60 and has ID which proves this. Let: A be Customer is under 18 B be Customer has a student card C be Customer is over 60 D be Customer has ID Q be Discount ticket issued Complete the Boolean expression below: Q≡ ………………………………………………………………………………………………… [3] © OCR 2022. You may photocopy this page. Page 2 of 20 Created in ExamBuilder 4(a). Show how the denary value −9.125 can be represented in normalised floating point format, using 8 bits for the mantissa and 4 bits for the exponent, both in two’s complement. …………………………………………………………………………………………………………………… …………………………………………………………………………………………………………………… …………………………………………………………………………………………………………………… …………………………………………………………………………………………………………………… …………………………………………………………………………………………………………………… …………………………………………………………………………………………………………………… …………………………………………………………………………………………………………………… …………………………………………………………………………………………………………………… [4] (b). Describe a mask that could be applied to an 8-bit number to ensure that: • • the most significant bit is always set to 1 all other bits remain unchanged. …………………………………………………………………………………………………………………… …………………………………………………………………………………………………………………… …………………………………………………………………………………………………………………… …………………………………………………………………………………………………………………… …………………………………………………………………………………………………………………… …………………………………………………………………………………………………………………… [2] © OCR 2022. You may photocopy this page. Page 3 of 20 Created in ExamBuilder 5*. A program is needed to plan the layout of a garden. The program will allow the user to create an image of the garden, for example: The programmer is designing the program to make use of caching and re-useable components. Explain and evaluate the use of caching and re-useable components in the design of the garden program. …………………………………………………………………………………………………………………… …………………………………………………………………………………………………………………… …………………………………………………………………………………………………………………… …………………………………………………………………………………………………………………… …………………………………………………………………………………………………………………… …………………………………………………………………………………………………………………… …………………………………………………………………………………………………………………… …………………………………………………………………………………………………………………… …………………………………………………………………………………………………………………… …………………………………………………………………………………………………………………… …………………………………………………………………………………………………………………… …………………………………………………………………………………………………………………… …………………………………………………………………………………………………………………… …………………………………………………………………………………………………………………… …………………………………………………………………………………………………………………… …………………………………………………………………………………………………………………… …………………………………………………………………………………………………………………… …………………………………………………………………………………………………………………… …………………………………………………………………………………………………………………… …………………………………………………………………………………………………………………… …………………………………………………………………………………………………………………… © OCR 2022. You may photocopy this page. Page 4 of 20 Created in ExamBuilder …………………………………………………………………………………………………………………… …………………………………………………………………………………………………………………… …………………………………………………………………………………………………………………… …………………………………………………………………………………………………………………… …………………………………………………………………………………………………………………… …………………………………………………………………………………………………………………… …………………………………………………………………………………………………………………… …………………………………………………………………………………………………………………… …………………………………………………………………………………………………………………… [9] 6 Staff working in a factory can report an IT problem to a help desk where details are recorded in a database. An engineer can then be allocated to resolve the problem. Two tables in the database are: Write an SQL statement to output the Date and Location for all problems allocated to the engineer with Surname Wong and Initial K. [2] ……………………………………………………………………………………………………………… ……………………………………………………………………………………………………………… ……………………………………………………………………………………………………………… [2] © OCR 2022. You may photocopy this page. Page 5 of 20 Created in ExamBuilder 7(a). A printer buffer is a storage area that holds the data, known as jobs that are to be printed by a printer. A simulation of the printer buffer uses a queue data structure to store jobs that are waiting to be printed. The queue is not circular. The printer buffer is represented as a zero-indexed 1D array with the identifier buffer. Fig. 2 shows the current contents of the queue buffer and its pointers. Fig. 2 (a) The function dequeue outputs and removes the next data item in the queue. The procedure enqueue adds the job passed as a parameter to the queue. Show the final contents of the queue and pointer values after the following instructions have been run on the queue buffer shown in Fig. 2. dequeue() dequeue() enqueue(job-128) dequeue() enqueue(job-129) [5] © OCR 2022. You may photocopy this page. Page 6 of 20 Created in ExamBuilder (b) The function enqueue returns -1 if there is no space at the end of the queue to add data, and returns 1 if the parameter was added to buffer. The array buffer contains a maximum of 100 elements. Write an algorithm, using pseudocode or program code, for the function enqueue(). [6] 8. Given the following procedure: procedure maths(number) a = (number DIV 10) * 10 b = a + 10 if (number – a) >= (b – number) then print(b) else print(a) endif endprocedure (a) State the value printed by the procedure maths if number=10 ………………….. [1] (b) State the purpose of the procedure maths. …………………………………………………………………………………………………………………… …………………………………………………………………………………………………………………… [1] © OCR 2022. You may photocopy this page. Page 7 of 20 Created in ExamBuilder 9(a). Bubble sorts make use of two different loops when sorting items into order. Describe the two loops used and their purpose. 1 2 [2] (b). Poppy would like to use a bubble sort to sort 250 000 numbers into order from lowest to highest. Currently the first five numbers before they have been sorted are: 195 584 167 147 158 187 160 125 184 236 Currently the last five numbers before they have been sorted are: 1058 19 558 1915 20 215 15 State the number of comparisons that will need to be made in the first pass of the bubble sort. [1] © OCR 2022. You may photocopy this page. Page 8 of 20 Created in ExamBuilder 10. Albert runs a competition each week in his local village hall. So that Albert can contact the winner he would like a program for the winner to enter their telephone number which is then checked and written into a text file. The rules for Albert’s program are as follows: 1. 2. 3. 4. 5. The telephone number is entered. This is checked to ensure that the first digit is a 0 If the first digit is not a 0 then a message saying “Needs To Start With 0” is printed If the first digit is a 0 then the telephone number is passed into a pre-existing function called checkLength as a parameter. This will return true if the length of the telephone number is long enough If the telephone number is long enough then it is written into a text file called "winner.txt" If the telephone number is not long enough then a message saying “Not Long Enough” is printed. Complete the procedure competitionWinner so that it meets the rules of Albert’s program. You should write your procedure using pseudocode. procedure competitionWinner() endprocedure [5] © OCR 2022. You may photocopy this page. Page 9 of 20 Created in ExamBuilder 11. Oscar owns a taxi company. He would like a program to handle taxi bookings from customers. Some of Oscar’s customers are rated as gold. Customers who are rated as gold are given priority when they make a taxi booking. Some customers rated as gold are shown here. Arshad Betty Dave Freddie Harry Jimmy Kanwal Lynn Siad Tommy Will When a customer makes a booking, Oscar will make use of a binary search to check if they are gold rated. Oscar would like to know if ‘Tommy’ is gold rated. State the three values that will be set as the midpoints and then checked against ‘Tommy’ on each iteration of the binary search. Show your working here. Midpoint 1 Midpoint 2 Midpoint 3 [3] © OCR 2022. You may photocopy this page. Page 10 of 20 Created in ExamBuilder 12(a). A supermarket uses an object-oriented approach to organise items that it offers for sale. Part of the class definition for the ItemForSale class is shown below. class ItemForSale public itemName public price public discount … endclass The supermarket has previously had issues with discounts being set as values above 50. Explain how encapsulation could be applied to the ItemForSale class to stop this problem from occurring. You are not expected to write any code in your answer to this question. [3] (b). The discount attribute represents a percentage discount on the price. The discount can be between 0 and 50 (inclusive). All new items for sale initially have a discount value of 0. (i) Write the constructor method for the ItemForSale class. [4] © OCR 2022. You may photocopy this page. Page 11 of 20 Created in ExamBuilder (ii) Write a line of code to create an object of type ItemForSale called mushypeas that has a name of “mushy peas” and a price of £0.89 [1] (iii) Write the calculatePrice() method, which applies the percentage discount to the price and returns the new value. [3] END OF QUESTION PAPER © OCR 2022. You may photocopy this page. Page 12 of 20 Created in ExamBuilder Mark scheme Question Answer/Indicative content 1 Software/program …that allows the operating system to communicate with hardware Examples: Printer driver Webcam driver Sound card driver Graphics card driver etc. Total Marks Guidance 3 AO1.1 (1) AO2.1 (2) Max two for description, Max one for example 3 1 mark per bullet up to a maximum of 2 marks, e.g: 2 Programs/data can be held in non-contiguous memory locations (using virtual addressing)… …making it easier to make best use of remaining storage/ to avoid having to move content around to fit in new programs. It allows pages to be transferred to and from secondary storage (i.e. virtual memory). As random access there is no performance drop vs sequential storage 2 AO1.2 (2) Accept (C∧D) ∨ (A∧B) Q = (A∧B) ∨ (C∧D) Accept (B∧A) instead of (A∧B) 3 3 1 mark for (A∧B) (AO1.2) 1 mark for (C∧D) Accept (D∧C) instead of (C∧D) Accept alternative notations (e.g. +/. OR / AND) Accept AB as (A.B) and CD as (C.D) 1 mark for the ∨ joining the two parts. Accept answers without brackets © OCR 2022. You may photocopy this page. Page 13 of 20 Created in ExamBuilder Examiner’s Comments In general, most candidates achieved all of the available marks in these questions. Total 4 a b 3 10110.111 in fixed point Gives mantissa of 10110111 exponent is 4 = 0100 Forming final answer of 10110111 0100 1000 0000 OR 4 AO1.2 2 AO2.2 Total 9 5 LOR check inventory 6 Total © OCR 2022. You may photocopy this page. 2 Page 14 of 20 Created in ExamBuilder 1 mark per pointer 7 a queueHead: Point to the first element in the queue / next element to remove queueTail: Point to the last element in the queue 2 AO1.2 (2) 1 mark per bullet up to max 5 first 3 jobs removed 128 and 129 added in positions 4 and 5 respectively no additional jobs queueHead being 3 (FT errors) queueTail being 5 (FT errors) b 5 AO2.1 (2) AO2.2 (3) The underlying implementation of the queue has not been specified, so allow alternative valid answers. e.g. queueHead = 0 queueTail = 2 Location 2: 129 Location 1: 128 Location 0: 127 1 mark per bullet to max 5 c i Function declaration Checking if queue is empty …returning null (Otherwise) incrementing queueHead …returning buffer[queueHead-1] e.g. function dequeue() if queueHead > queueTail then return null else queueHead = queueHead + 1 return buffer[queueHead-1] endif endfunction 1 mark per bullet to max 6 ii Function declaration taking parameter Checking if queue is full © OCR 2022. You may photocopy this page. Page 15 of 20 5 AO2.2 (2) AO3.3 (3) Note: Accept alternative valid underlying implementation answers e.g. Shifting all elements in queue forward. 6 AO2.2 (3) AO3.3 (3) Created in ExamBuilder …returning -1 (Otherwise) incrementing queueTail Adding newJob to buffer(queueTail) Returning 1 e.g. function enqueue(newJob) if queueTail == 99 then return -1 else queueTail = queueTail + 1 buffer[queueTail] = newJob return 1 endif endfunction 1 mark per bullet to max 8 Inputting user choice If enqueue chosen input job name …call enqueue with input value as parameter …check if return value is -1 and output full …otherwise output message that item is added If dequeue chosen …call dequeue and save returned value …output returned value (jobname) if not null …or output queue is empty iii e.g. main() choice = input("Add or remove?") 8 AO2.2 (2) AO3.3 (6) if choice == "ADD" then jobname = input("Enter job name") returnValue = enqueue(jobname) if returnValue == -1 then print("Queue full") Allow equivalent checks / logic else print("Job added") endif else returnValue = dequeue() if returnValue == null then print("Queue empty") else output returnValue © OCR 2022. You may photocopy this page. Page 16 of 20 Created in ExamBuilder endif endif endmain 1 mark per bullet to 3 d Check if either head or tail are incremented to above 99 … set to be 0 instead When checking if array is full check if (queueTail == queueHead – 1) OR (queueTail==99 AND queueHead==0) 3 AO2.1 (1) AO2.2 (2) Credit equivalent modulo arithmetic solution 1 mark per bullet to max 3, e.g. e Use a different structure e.g. a linked list …items can be added at different points in the linked list depending on priority …by changing the pointers to items needing priority Have different queues for different priorities …add the job to the queue relevant to its priority …print all the jobs in the highest priority queue first Total 3 AO2.1 (2) AO2.1 (1) Allow other suitable descriptions that show how the program could be amended. 32 1 8 a A03.2 (1) b 10 To round the number to the nearest 10 © OCR 2022. You may photocopy this page. Page 17 of 20 1 A02.1 (1) Created in ExamBuilder 1 mark per bullet up to a maximum of 4 marks: 9 a b The inner loop will compare all of the adjacent items in a single pass The outer loop will repeat the process of checking adjacent items until all passes are complete / the items are sorted/no swaps have been made in a pass 2 A01.2 (4) 1 A02.2 (1) 249,999 Total 5 1 mark per bullet up to a maximum of 5 marks, e.g.: 10 Allow other valid interpretations e.g. conditional while loop … used to compare against swap flag after each pass; counter controlled for loop … used to check adjacent items on each pass Suitable logic for inputting the telephone number Suitable logic for ensuring the telephone number starts with a 0 Suitable logic for passing the telephone number into the function checkLength If true, suitable logic for opening and closing winner.txt …suitable logic for writing the telephone number to winner.txt Suitable logic for printing “Needs To Start With 0” and "Not Long Enough" Total © OCR 2022. You may photocopy this page. Example Solution: procedure competitionWinner() telNum = input("Enter Telephone Number") if telNum[0] == "0" then length = checkLength(telNum) 5 AO3.1 (2) AO3.2 (3) if length == true then myfile = openWrite("winner.txt") myfile.writeLine(telNum) myfile.close() else print ("Not Long Enough") endif else print (“Needs To Start With 0”) endif endprocedure() 5 Page 18 of 20 Created in ExamBuilder 1 mark per bullet up to a maximum of 3 marks: 11 i 5 (Jimmy) 8 (Siad) 9 (Tommy) discount attribute made private Set method created …that restricts value to maximum 50% 12 a b i 3 A02.1 (3) Constructor method definition (.e.g new) itemname, price passed in as parameters (must use different identifier names to the ones in the question) …and assigned to attributes discount attribute assigned to 0. 3 AO2.2 4 AO3.2 Example answer public procedure new(nItemName, nPrice) itemname = nItemname price = nPrice discount = 0 endprocedure Look out for alternative notation e.g. this.itemname = itemName Example answers mushypeas=new ItemForSale("mushy peas", 0.89) ii creating object with identifier mushypeas = and type ItemForSale with parameters passed in as needed 1 AO3.2 ItemForSale mushypeas = ItemForSale(“mushy peas”,0.89); mushypeas=ItemForSale((“mushy peas”,0.89); Do not penalise for use of self parameter as used by languages such as Python. Must be correct case and spelling iii method definition for calculatePrice() applies percentage discount …returns calculated value © OCR 2022. You may photocopy this page. Page 19 of 20 Percentage discount must be applied correctly. 3 AO3.2 Example answer function calculatePrice() newPrice = price – (price * discount/100) Created in ExamBuilder return newPrice end function Total © OCR 2022. You may photocopy this page. 13 Page 20 of 20 Created in ExamBuilder