ExamBank Scot · AH Computing Science question bank · All AH Computing Science questions

AH Computing Science 2017 Question 4 (CfE)

15 marks · Feasibility studies and user surveys

At the start of the development, Ali needs to research the four most common feelings experienced by young children. Explain how a user survey could be used for this purpose. Ali wants to display images of each of the four feelings randomly when the program starts and decides to allocate each image a number between 1 and 4. The program will select a number between 1 and 4 before placing each number into a 2-D array. Below, the contents of a sample game board array are shown on the left and the matching set of images displayed when the program starts is shown on the right. Sample game board array 1 4 2 1 4 2 3 1 2 3 Matching set of images displayed 3 4 2 3 2 1 1 3 2 4 1 2 4 1 1 3 4 1 3 4 4 3 3 4 1 3 2 4 2 2 Ali wants each of the four images to appear exactly 10 times. The images should be displayed in the layout indicated above, with eight images in each of the five rows. Use pseudocode to design a procedure which assigns a random number between one and four to each element in the 2-D game board array. Your design should indicate: • the selection of 40 random numbers between 1 and 4 • a check to ensure that each number appears exactly 10 times • the storage of the numbers selected in the 2-D array You should assume that the game board array will be passed to the procedure as a parameter. Having matched a pair of images, the child is then required to complete a sentence about their feelings. The program allows the child to enter one or more sentence endings. Any sentence endings entered are added to the existing list of endings and stored so that they can be viewed the next time the game is played. I feel happy when I ... bake cakes Add Happy visit the zoo go swimming Remove ride my bike Return to Game play in the park Ali decides to use a linked list to store the sentence endings. He plans to write the sentence endings held in the linked list to a sequential file called happyFeelings.txt. Using a programming language with which you are familiar, create a procedure to write the contents of the linked list to the happyFeelings.txt file. You should state any assumptions you make about how the linked list is implemented within the procedure. The image below demonstrates how Ali has written his program using concurrent programming techniques. Program Application Thread B User Space Thread C Thread A A B C Kernal (Operating System) Keyboard Hard Disk The program uses multiple threads. Thread A is used to interact with the keyboard, Thread B is used to manage the program application and Thread C is used to automatically backup and save the program data every two minutes. Explain why the use of multiple threads improves the performance of the program and gives a better user experience. As a self-employed developer, Ali is concerned about his intellectual property rights in relation to the program. Describe one form of automatic protection Ali receives when creating the program. Ali has been asked by a local primary school to create a program which allows young children to express their feelings. The program will be based on a pairs matching game. When the program starts, 40 images representing the four most common feelings will be displayed and the child asked to match any two of the images.

Marking scheme

Ali would ask stakeholders (parents, teachers, young primary pupils) to list/rank/identify the feelings they find young children using most often; she would ask the target audience (young children) to complete the surveys by saying what their most common emotion or feeling was. Once the surveys had been completed by a large group of the target audience, the results would be analysed to determine the 4 most commonly used emotions for the age group. 1 mark for source(s) of the information gathered 1 mark for description of details gathered in the survey Many different solutions are possible. One solution is provided below. 1. declare 1D array of integers to store quantity of each image 2. initialise quantity array to 0 3. repeat rows from 0 to 4 4. repeat columns from 0 to 7 5. selectNumber 6. store selected number in array[row, column] 7. end repeat 8. end repeat 5.1 set valid to false 5.2 while not valid 5.3 select random number between 1 and 4 5.4 if quantity of that number <10 then 5.5 add 1 to quantity 5.6 set valid to true 5.7 else 5.8 select random number between 1 and 4 5.9 end if 5.10 end while 1 mark for appropriate use made of local variables or 1D array to store count of each random number 1 mark for correct use nested loop structure Max 2 marks allocated to check: 1 mark for comparison of counts with 10; 1 mark for taking appropriate action when count exceeds 10 1 mark for correct storage in 2-D array Assumptions: • linked list is implemented as an array of nodes which is passed to the procedure • RECORD Nodes IS { STRING ending, INTEGER pointer } • head of list is element 0 • pointer of tail of list contains value 999 PROCEDURE outputToFile (ARRAY of Nodes array) DECLARE index INITIALLY 0 OPEN file "happyFeelings.txt" WHILE head <> 999 DO SEND array.ending[index] TO file "happyFeelings.txt" SET index TO array.pointer[index] END WHILE CLOSE file "happyFeelings.txt" END PROCEDURE 1 mark for file handling (OPEN, SEND, WRITE, CLOSE) Max 3 marks for handling linked list: 1 mark for traversing the list 1 mark for use of head/tail 1 mark for writing node data value to file Note: many alternative solutions are possible Creating Thread C means that Threads A & B would not be interrupted when the backup started. As a result, the user experience wouldn’t be slowed down/ interrupted while the backup was performed. If Thread C wasn’t programmed then commands from the keyboard would be ignored until the backup was complete. Award max 2 marks for any 2 of the following: 1 mark no interruption/time split between only two threads 1 mark keyboard commands when ignored would result in sluggish performance when using the keyboard. 1 mark for appropriate description of multiple threads Note: full marks can only be allocated if answer relates back to the scenario provided Copyright Ali will automatically gain Copyright protection for any original artwork she has created for the program. Ali will automatically gain Copyright protection on the program/source code she has written. Copyright protection protects Ali’s work and stops others from using it without her permission. Copyright prevents people from: • copying her work • distributing copies of it, whether free of charge or for sale • renting or lending copies of her work • performing, showing or playing her work in public • making an adaptation of her work • putting it on the internet Design Right Ali will automatically gain Design Right protection on the design of her program. Design right automatically protects Ali’s design for 10 years after it was first sold or 15 years after it was created - whichever is earliest. 1 mark for either copyright or design right 1 mark for accurate description of named protection

Previous question: AH Computing Science 2017 Question 3 (CfE)

Next question: AH Computing Science 2018 Question 1 (CfE)