Difference between revisions of "2011 Old Spec"

From TRCCompSci - AQA Computer Science
Jump to: navigation, search
(Created page with " =Question 7= The variable table, Table 4, and the Structured English algorithm, Figure 4, describe a linear search algorithm that could be used with a simplified version of...")
 
 
Line 9: Line 9:
  
 
==Table 4==
 
==Table 4==
 
  
 
{| |-
 
{| |-
Line 37: Line 36:
 
|}
 
|}
 
<br>
 
<br>
 
  
  
 
==Figure 4==
 
==Figure 4==
 
  
 
     Names[1] = 'Ben'<br>
 
     Names[1] = 'Ben'<br>
Line 62: Line 59:
 
         ELSE OUTPUT 'No, they do not have a top score'<br>
 
         ELSE OUTPUT 'No, they do not have a top score'<br>
 
     ENDIF<br>
 
     ENDIF<br>
 
 
  
  
 
==What you need to do==
 
==What you need to do==
 
  
 
#Write a program for the above algorithm.
 
#Write a program for the above algorithm.
 
#Test the program by searching for a player named 'Thor'.
 
#Test the program by searching for a player named 'Thor'.
 
#Test the program by searching for a player named 'Imran'.
 
#Test the program by searching for a player named 'Imran'.

Latest revision as of 10:34, 29 November 2016

Question 7

The variable table, Table 4, and the Structured English algorithm, Figure 4, describe a linear search algorithm that could be used with a simplified version of the Dice Cricket game to find out if a particular player’s name appears in the high score table.

In this simplified version only the names of the players getting a top score are stored. Their scores are not stored.


Table 4

Identifier Data Type Purpose
Names Array[1..4] of String Stores the names of the players
PlayerName String Stores the name of the player being looked for
Max Integer Stores the size of the array
Current Integer Indicates which element of the array Names is currently being examined
Found Boolean Stores True if the player’s name has been found in the array, False otherwise



Figure 4

   Names[1] = 'Ben'
Names[2] = 'Thor'
Names[3] = 'Zoe'
Names[4] = 'Kate'
Max = 4
Current = 1
Found = False
OUTPUT 'What player are you looking for?'
INPUT PlayerName
WHILE (Found = False) AND (Current <= Max)
IF Names[Current] = PlayerName
THEN Found = True
ELSE Current = Current + 1
ENDIF
ENDWHILE
IF Found = True
THEN OUTPUT 'Yes, they have a top score'
ELSE OUTPUT 'No, they do not have a top score'
ENDIF


What you need to do

  1. Write a program for the above algorithm.
  2. Test the program by searching for a player named 'Thor'.
  3. Test the program by searching for a player named 'Imran'.