Question 9
AQA Computer Science June 2018 Paper 1A level9 marks
On the specification
- 9.1
- 3.1 Fundamentals of programming4.3 Fundamentals of algorithms
- 9.2
- 3.3 Systematic approach to problem solving
Question text
9 This question refers to the subroutine CheckWordIsValid. When a player enters a word, a linear search algorithm is used to check to see if the word entered is in the list of AllowedWords. The subroutine CheckWordIsValid is to be changed so that it uses a more time-efficient search algorithm. Change the CheckWordIsValid subroutine so that it uses a binary search algorithm instead of a linear search algorithm. You must write your own search routine and not use any built-in search function that might be available in the programming language you are using. Each item in AllowedWords that is compared to the word that the user entered should be displayed on the screen. Figure 4 shows examples of how the new version of CheckWordIsValid should work if AllowedWords contained the items shown in Figure 3. Figure 3 BIG BUG FED GET JET NOT SIP WON Figure 4 1) If the user enters the word BIG then a value of True should be returned and the words GET, BUG, BIG should be displayed, in that order. 2) If the user enters the word JET then a value of True should be returned and the words GET, NOT, JET should be displayed, in that order. 3) If the user enters the word ZOO then a value of False should be returned and the words GET, NOT, SIP, WON should be displayed, in that order. Test that the changes you have made work: • run the Skeleton Program • if you have answered Question 8, enter 15 when asked to enter the start hand size; if you have not answered Question 8 yet then skip this step • enter 2 at the main menu • enter the word jars. Evidence that you need to provide Include the following in your Electronic Answer Document. 9.1 Your PROGRAM SOURCE CODE for the amended subroutine CheckWordIsValid. [8 marks] 9.2 SCREEN CAPTURE(S) showing the requested test. [1 mark]