A-Level: Computer Science
A-Level: Computer Science
Computer Science
7517/1 - Paper 1
June 2018
Mark schemes are prepared by the Lead Assessment Writer and considered, together with the relevant
questions, by a panel of subject teachers. This mark scheme includes any amendments made at the
standardisation events which all associates participate in and is the scheme which was used by them in
this examination. The standardisation process ensures that the mark scheme covers the students’
responses to questions and that every associate understands and applies it in the same correct way.
As preparation for standardisation each associate analyses a number of students’ scripts. Alternative
answers not already covered by the mark scheme are discussed and legislated for. If, after the
standardisation process, associates encounter unusual answers which have not been raised they are
required to refer these to the Lead Assessment Writer.
It must be stressed that a mark scheme is a working document, in many cases further developed and
expanded on the basis of students’ reactions to a particular paper. Assumptions about future mark
schemes on the basis of one year’s document should be avoided; whilst the guiding principles of
assessment remain constant, details will change, depending on the content of a particular examination
paper.
June 2018
Pages 21 to 43 contain the ‘Program Source Code’ specific to the programming languages for
questions 5, 7, 8, 9, 10 and 11.
pages 21 to 23 – PYTHON 2
pages 24 to 26 – PYTHON 3
pages 26 to 30 – VB.NET
pages 31 to 35 – C#
pages 36 to 40 – JAVA
pages 41 to 43 – PASCAL/Delphi
3
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
Before you apply the mark scheme to a student’s answer read through the answer and annotate
it (as instructed) to show the qualities that are being looked for. You can then apply the mark
scheme.
When assigning a level you should look at the overall quality of the answer and not look to pick
holes in small and specific parts of the answer where the student has not performed quite as
well as the rest. If the answer covers different aspects of different levels of the mark scheme
you should use a best fit approach for defining the level and then use the variability of the
response to help decide the mark within the level, ie if the response is predominantly level 3
with a small amount of level 4 material it would be placed in level 3 but be awarded a mark near
the top of the level because of the level 4 content.
You may well need to read back through the answer as you apply the mark scheme to clarify
points and assure yourself that the level and the mark are appropriate.
Indicative content in the mark scheme is provided as a guide for examiners. It is not intended to
be exhaustive and you must credit other valid points. Students do not have to cover all of the
points mentioned in the Indicative content to reach the highest level of the mark scheme.
An answer which contains nothing of relevance to the question must be awarded no marks.
4
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
Examiners are required to assign each of the candidate’s responses to the most appropriate
level according to its overall quality, and then allocate a single mark within the level. When
deciding upon a mark in a level examiners should bear in mind the relative weightings of the
assessment objectives
eg
In question 7.1, the marks available for the AO3 elements are as follows:
Where a candidate’s answer only reflects one element of the AO, the maximum mark they can
receive will be restricted accordingly.
5
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
If it is an onion then the box labelled "onions" contains carrots and the box
labelled "carrots" contains onions and carrots. If it is a carrot then the box
labelled "carrots" contains onions and the box labelled "onions" contains carrots
and onions;
53-
342*+1–
Mark as follows:
1 mark: correct order for values and + and – either side of the 1
1 mark: * directly after 4 2
Max 2
Each time operator reached pop top two values off stack (and apply operator to
them);
6
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
local variables;
return address;
parameters;
register values; A. example of register that would be in stack frame
Max 2
1 2 3 4 5 6
1 0 2 5 3 0 8
2 2 0 1 0 0 0
3 5 1 0 0 0 4
4 3 0 0 0 1 0
5 0 0 0 1 0 5
6 8 0 4 0 5 0
Alternative answer
1 2 3 4 5 6
1 0 2 5 3 0 8
2 0 1 0 0 0
3 0 0 0 4
4 0 1 0
5 0 5
6 0
7
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
Alternative answer
1 2 3 4 5 6
1 0
2 2 0
3 5 1 0
4 3 0 0 0
5 0 0 0 1 0
6 8 0 4 0 5 0
Mark as follows:
I. non-zero symbols used to denote no edge but only for showing no edge going
from a node to itself
Adjacency list appropriate when there are few edges between vertices // when
graph/matrix is sparse; NE. few edges
Max 2
8
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
Mark as follows:
I. output column
1 mark: first value of A is 2
1 mark: second value of A is 5 and third value is 3
1 mark: fourth and subsequent values of A are 8, 3, 7, 4, 9 with no more values
after this
1 mark: D[2] is set to 2 and then does not change
D P
U Q V A 1 2 3 4 5 6 1 2 3 4 5 6
- 1,2 - - 20 20 20 20 20 20 -1 -1 -1 -1 -1 -1
,3,
4,5
,6
1 2,3 2
,4, 2 2 1
5,6
3 5 5 1
4 3 3 1
6 8 8 1
2 3,4 3
,5, 3 3 2
6
3 4,5 6
7 7 3
,6
4 5,6 5 4 4 4
5 6 6 9
6 -
9
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
1 mark: D[3] is set to 5 and then changes to 3 and does not change again
1 mark: correct final values for each position of array P
D P
U Q V A 1 2 3 4 5 6 1 2 3 4 5 6
- 1,2 - - 20 20 20 20 20 20 -1 -1 -1 -1 -1 -1
,3,
4,5
,6
1 2,3 2
,4, 2 2 1
5,6
3 5 5 1
4 3 3 1
6 8 8 1
2 3,4 3
,5, 3 3 2
6
3 4,5 6
7 7 3
,6
4 5,6 5 4 4 4
5 6 6 9
6 -
10
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
D P
U Q V A 1 2 3 4 5 6 1 2 3 4 5 6
- 1,2 - - 20 20 20 20 20 20 -1 -1 -1 -1 -1 -1
,3,
4,5
,6
1 2,3 2
,4, 2 2 1
5,6
3 5 5 1
4 3 3 1
6 8 8 1
2 3,4 3
,5, 3 3 2
6
3 4,5 6
7 7 3
,6
4 5,6 5 4 4 4
5 6 6 9
6 -
11
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
Used to store the previous node/location in the path (to this node);
Max 1 if not clear that the values represent the shortest path
Alternative answer
Max 1 if not clear that the values represent the shortest path
Max 1 for the following points, but only award mark if 1st mark was awarded:
In general, inspection alone cannot always determine whether any given algorithm
will halt for its given inputs // a program cannot be written that can determine
whether any given algorithm will halt for its given inputs;
Max 1 mark
12
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
A Turing machine that can execute/simulate the behaviour of any other Turing
machine // can compute any computable sequence;
Description of/Instructions for TM (and the TM's input) are stored on the (Universal
Turing machine's) tape // The UTM acts as an interpreter; A. take any other TM
and data as input
Alternative definition:
A UTM, U, is an interpreter that reads the description <M> of any arbitrary Turing
machine M;
The description <M> is written at the beginning of the tape, followed by D.;
Max 2 marks
13
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
Mark Scheme
14
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
Guidance
Note that AO3 (design) points are for selecting appropriate techniques to use to
solve the problem, so should be credited whether the syntax of programming
language statements is correct or not and regardless of whether the solution
works.
15
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
12. In an appropriate location in the code asks the user if they want to enter
another number R. if message will not be displayed after each time the user
has entered a number
Note for examiners: if a candidate produces an unusual answer for this question
which seems to work but does not match this mark scheme then this answer
should be referred to team leader for guidance on how it should be marked.
Screen captures showing the number 1 being entered with the message “Not
greater than 1” displayed, then the number 5 being entered with the message “Is
prime” displayed and then the number 8 being entered with the message “Is not
prime” being displayed and program stops after user input stating they do not want
to enter another number;
Enter a number: 1
Not greater than 1
Again (y or n)? y
Enter a number: 5
Is prime
Again (y or n)? y
Enter a number: 8
Is not prime
Again (y or n)? n
>>>
16
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
I. case
I. spacing
R. if any additional code
A. MaxSize
I. case
I. spacing
R. if any additional code
R. if spelt incorrectly
Mark as follows
Check for 1st mark point from either solution 1 or solution 2.
2nd mark point for Solution 1 only to be awarded if 1st mark point for Solution
1 has been awarded.
2nd mark point for Solution 2 only to be awarded if 1st mark point for Solution
2 has been awarded
Solution 1
1st mark: With a linear queue there could be locations available that are not able to
be used A.there could be wasted space
(where there is space available in the data structure but it is unusable as it is in
front of the data items in the queue);
2nd mark:
(To avoid this issue) items in the queue are all shuffled forward when an item is
deleted from (the front of the) queue;
//
Circular lists “wrap round” so (avoid this problem as) the front of the queue does
not have to be in the first position in the data structure;
17
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
Solution 2
Alternative answer
1st mark:
Items in a linear queue are all shuffled forward when an item is deleted from (the
front);
//
No need to shuffle items forward after deleting an item in a circular queue;
2nd mark:
this makes (deleting from) (large) linear lists time inefficient;
//
meaning circular queues are more time efficient (when deleting);
The queue is small in size (so the time inefficiency is not significant);
Otherwise generate a random number from the other numbers between 0 and 25 //
otherwise generate a random number from those equivalent to non 1-point tiles;
Note for examiners: refer unusual answers that would work to team leader
Subtract 32 from the character code // AND the character code with the bit pattern
1011111 / 11011111 // AND the character code with (the decimal value) 95 / 223;
A. Hexadecimal equivalents
Convert that value back into a character and replace the current character with the
new character;
A. answers that create a new string instead of replace characters in the existing
string
18
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
Alternative answer
Using a list of the lowercase letters and a list of the uppercase letters;
Find the index of the lowercase letter in the list of lowercase letters;
Get the character in the corresponding position in the uppercase list and replace
the current character with the new character;
A. answers that create a new string instead of replace characters in the existing
string
19
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
Selection structure with correct condition(s) (9, 23) added in suitable place and
value of 4 assigned to two tiles in the dictionary;
Screen captures showing the requested test being performed and the correct
points values for J, X, Z and Q are shown; I. order of letters
TILE VALUES
Points for X: 4
Points for R: 1
Points for Q: 5
Points for Z: 5
Points for M: 2
Points for K: 3
Points for A: 1
Points for Y: 3
Points for L: 2
Points for I: 1
Points for F: 3
Points for H: 3
Points for D: 2
Points for U: 2
Points for N: 1
Points for V: 3
Points for T: 1
Points for E: 1
Points for W: 3
Points for C: 2
Points for G: 2
Points for P: 2
Points for J: 4
Points for O: 1
Points for B: 2
Points for S: 1
Either:
enter the word you would like to play OR
press 1 to display the letter values OR
press 4 to view the tile queue OR
press 7 to view your tiles again OR
press 0 to fill hand and stop the game.
20
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
Screen capture(s) showing that after the values 0 and 21 are entered the user is
asked to enter the start hand size again and then the menu is displayed;
++++++++++++++++++++++++++++++++++++++
+ Welcome to the WORDS WITH AQA game +
++++++++++++++++++++++++++++++++++++++
=========
MAIN MENU
=========
21
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
1) Create variables to store the current start, mid and end points; A. no
variable for midpoint if midpoint is calculated each time it is needed in the
code
2) Setting correct initial values for start and end variables;
3) Iterative structure with one correct condition (either word is valid or start is
greater than end); R. if code is a linear search
4) Iterative structure with 2nd correct condition and correct logic;
5) Inside iterative structure, correctly calculate midpoint between start and
end;
A. mid-point being either the position before or the position after the exact
middle if calculated midpoint is not a whole number R. if midpoint is
sometimes the position before and sometimes the position after the exact
middle R. if not calculated under all circumstances when it should be
6) Inside iterative structure there is a selection structure that compares word
at midpoint position in list with word being searched for;
7) Values of start and end changed correctly under correct circumstances;
8) True is returned if match with midpoint word found and True is not returned
under any other circumstances;
22
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
1) Create variable to store the current midpoint, start and end points passed
as parameters to subroutine; A. no variable for midpoint if midpoint is
calculated each time it is needed in the code A. midpoint as parameter
instead of as local variable
2) Initial subroutine call has values of 0 for startpoint parameter and number of
words in AllowedWords for endpoint parameter;
3) Selection structure which contains recursive call if word being searched for
is after word at midpoint;
4) Selection structure which contains recursive call if word being searched for
is before word at midpoint;
5) Correctly calculate midpoint between start and end;
A. midpoint being either the position before or the position after the exact
middle if calculated midpoint is not a whole number R. if midpoint is
sometimes the position before and sometimes the position after the exact
middle R. if not calculated under all circumstances when it should be
6) There is a selection structure that compares word at midpoint position in list
with word being searched for and there is no recursive call if they are equal
with a value of True being returned;
7) In recusive calls the parameters for start and end points have correct
values;
8) There is a selection structure that results in no recursive call and False
being returned if it is now known that the word being searched for is not in
the list;
Note for examiners: mark points 1, 2, 7 could be replaced by recursive calls that
appropriately half the number of items in the list of words passed as a parameter –
this would mean no need for start and end points. In this case award one mark for
each of the two recursive calls if they contain the correctly reduced lists and one
mark for the correct use of the length function to find the number of items in the list.
These marks should not be awarded if the list is passed by reference resulting in
the original list of words being modified.
23
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
Screen capture(s) showing that the word “jars” was entered and the words
“MALEFICIAL”, “DONGLES”, “HAEMAGOGUE”, “INTERMINGLE”, “LAGGER”,
“JOULED”, “ISOCLINAL”, “JAUKING”, “JACARANDA”, “JAMBEUX”, “JAPONICA”,
“JAROVIZE”, “JASPER”, “JARTA”, “JARRAH”, “JARRINGLY”, “JARS” are
displayed in that order;
Screen capture(s) showing that the word “jars” was entered and the words
“MALEATE”, “DONDER”, “HADST”, “INTERMENDIS”, “LAGAN”, “JOTTERS”,
“ISOCHROMATIC”, “JASPERS”, “JABBING”, “JALOUSIE”, “JAPANISES”,
“JARGOONS”, “JARRED”, “JASIES”, “JARUL”, “JARS” are displayed in that order;
Screen capture(s) showing that the word “jars” was entered and the words “LAMP”,
“DESK”, “GAGE”, “IDEAS”, “INVITATION”, “JOURNALS”, “JAMAICA”,
“JEWELLERY”, “JEAN”, “JAR”, “JAY”, “JASON”, “JARS” are displayed in that
order;
Either:
enter the word you would like to play OR
press 1 to display the letter values OR
press 4 to view the tile queue OR
press 7 to view your tiles again OR
press 0 to fill hand and stop the game.
>jars
MALEFICIAL
24
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
DONGLES
HAEMAGOGUE
INTERMINGLE
LAGGER
JOULED
ISOCLINAL
JAUKING
JACARANDA
JAMBEUX
JAPONICA
JAROVIZE
JASPER
JARTA
JARRAH
JARRINGLY
JARS
Valid word
25
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
Alternative answer
If answer looks at each letter in AllowedWords in turn and maintains a count (eg in
array/list) for the number of each letter found then mark points 2 and 5 should be:
2) Creation of suitable data structure to store 26 counts.
26
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
H 60702
I 220483
J 4010
K 22076
L 127865
M 70700
N 163637
O 161752
P 73286
Q 4104
R 170522
S 234673
T 159471
U 80636
V 22521
W 18393
X 6852
Y 39772
Z 11772
Either:
enter the word you would like to play OR
press 1 to display the letter values OR
press 4 to view the tile queue OR
press 7 to view your tiles again OR
press 0 to fill hand and stop the game.
>
27
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
Y 39760
Z 11765
Either:
enter the word you would like to play OR
press 1 to display the letter values OR
press 4 to view the tile queue OR
press 7 to view your tiles again OR
press 0 to fill hand and stop the game.
>
Either:
enter the word you would like to play OR
press 1 to display the letter values OR
press 4 to view the tile queue OR
press 7 to view your tiles again OR
press 0 to fill hand and stop the game.
>
28
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
6) Selection structure for differentiating base case and recursive case with
suitable condition (word length of 0 // 1 // 2); R. if base case will result in
recursion
7) If base case is word length is 0 then value of 0 is returned by subroutine
and there is no recursive call // if base case is word length is 1 then value of
0 is returned by subroutine and there is no recursive call // if base case is
word length is 2 the the subroutine returns 0 if the two-letter word is not a
valid word and returns the score for the two-letter word if it is a valid word;
8) Selection structure that contains code that adds value returned by call to
GetScoreForWord to score if word is valid; A. no call to subroutine
GetScoreForWord if correct code to calculate score included in sensible
place in GetScoreForWordAndPrefix subroutine R. if no check for
word being valid
9) Call to GetScoreForWordAndPrefix;
10) Result from recursive call added to score;
11) Recursion will eventually reach base case as recursive call has a
parameter that is word with last letter removed;
29
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
Mark points 1-5 same as for recursive attempt. No marks awarded for mark points
6-11, instead award marks as appropriate for mark points 12-14.
12) Adds the score for the original word to the score once // sets the initial
score to be the score for the original word; A. no call to subroutine
GetScoreForWord if correct code to calculate score included in sensible
place in GetScoreForWordAndPrefix subroutine. Note for
examiners: there is no need for the answer to check if the original word is
valid
13) Iterative structure that will repeat n - 1 times where n is the length of the
word; A. n – 2 A. n
14) Inside iterative structure adds score for current prefix word, if it is a valid
word, to score once; A. no call to GetScoreForWord if own code to
calculate score is correct
Screen capture(s) showing that the word abandon was entered and the new score
of 78 is displayed;
30
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
Python 2
05 1 import math 12
again = "y"
while again == "y":
num = int(raw_input("Enter a number: "))
if num > 1:
prime = True
for count in range(2, int(math.sqrt(num)) + 1):
if num % count == 0:
prime = False
if prime == True:
print "Is prime"
else:
print "Is not prime"
else:
print "Not greater than 1"
again = raw_input("Again (y or n)? ")
07 1 def CreateTileDictionary(): 2
TileDictionary = dict()
for Count in range(26):
if Count in [0, 4, 8, 13, 14, 17, 18, 19]:
TileDictionary[chr(65 + Count)] = 1
elif Count in [1, 2, 3, 6, 11, 12, 15, 20]:
TileDictionary[chr(65 + Count)] = 2
elif Count in [5, 7, 10, 21, 22, 24]:
TileDictionary[chr(65 + Count)] = 3
elif Count in [9, 23]:
TileDictionary[chr(65 + Count)] = 4
else:
TileDictionary[chr(65 + Count)] = 5
return TileDictionary
08 1 … 4
StartHandSize = int(raw_input("Enter start hand size:
"))
while StartHandSize < 1 or StartHandSize > 20:
StartHandSize = int(raw_input("Enter start hand size:
"))
…
31
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
10 1 def CalculateFrequencies(AllowedWords): 8
print "Letter frequencies in the allowed words are:"
for Code in range (26):
LetterCount = 0
LetterToFind = chr(Code + 65)
for Word in AllowedWords:
for Letter in Word:
if Letter == LetterToFind:
LetterCount += 1
sys.stdout.write(LetterToFind + " " + LetterCount)
Alternative answer
def CalculateFrequencies(AllowedWords):
for Letter in "ABCDEFGHIJKLNOPQRSTYVWXYZ":
Count=0
for Word in AllowedWords:
NumberOfTimes = Word.count(Letter)
Count = Count + NumberOfTimes
sys.stdout.write(Letter + " " + str(Count))
Alternative answer
def CalculateFrequencies(AllowedWords):
Counts = []
for a in range(26):
Counts.append(0)
for Word in AllowedWords:
for Letter in Word:
Counts[ord(Letter) - 65] += 1
for a in range(26):
sys.stdout.write(chr(a + 65) + " " + str(Counts[a]))
32
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
Alternative answer
def GetScoreForWordAndPrefix(Word,TileDictionary,
AllowedWords):
Score = 0
if CheckWordIsValid(Word,AllowedWords):
Score += GetScoreForWord(Word, TileDictionary)
if len(Word[:-1]) > 0:
Score +=GetScoreForWordAndPrefix(Word[:-1],
TileDictionary,AllowedWords)
return Score
33
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
Python 3
05 1 import math 12
again = "y"
while again == "y":
num = int(input("Enter a number: "))
if num > 1:
prime = True
for count in range(2, int(math.sqrt(num)) + 1):
if num % count == 0:
prime = False
if prime == True:
print("Is prime")
else:
print("Is not prime")
else:
print("Not greater than 1")
again = input("Again (y or n)? ")
07 1 def CreateTileDictionary(): 2
TileDictionary = dict()
for Count in range(26):
if Count in [0, 4, 8, 13, 14, 17, 18, 19]:
TileDictionary[chr(65 + Count)] = 1
elif Count in [1, 2, 3, 6, 11, 12, 15, 20]:
TileDictionary[chr(65 + Count)] = 2
elif Count in [5, 7, 10, 21, 22, 24]:
TileDictionary[chr(65 + Count)] = 3
elif Count in [9, 23]:
TileDictionary[chr(65 + Count)] = 4
else:
TileDictionary[chr(65 + Count)] = 5
return TileDictionary
08 1 … 4
StartHandSize = int(input("Enter start hand size: "))
while StartHandSize < 1 or StartHandSize > 20:
StartHandSize = int(input("Enter start hand size: "))
…
34
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
10 1 def CalculateFrequencies(AllowedWords): 8
print("Letter frequencies in the allowed words are:")
for Code in range (26):
LetterCount = 0
LetterToFind = chr(Code + 65)
for Word in AllowedWords:
for Letter in Word:
if Letter == LetterToFind:
LetterCount += 1
print(LetterToFind, " ", LetterCount)
Alternative answer
def CalculateFrequencies(AllowedWords):
for Letter in "ABCDEFGHIJKLNOPQRSTYVWXYZ":
Count=0
for Word in AllowedWords:
NumberOfTimes = Word.count(Letter)
Count = Count + NumberOfTimes
print(Letter,Count)
Alternative answer
def CalculateFrequencies(AllowedWords):
Counts = []
for a in range(26):
Counts.append(0)
for Word in AllowedWords:
for Letter in Word:
Counts[ord(Letter) - 65] += 1
for a in range(26):
print(chr(a + 65), Counts[a])
35
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
Alternative answer
def GetScoreForWordAndPrefix(Word,TileDictionary,
AllowedWords):
Score = 0
if CheckWordIsValid(Word,AllowedWords):
Score += GetScoreForWord(Word, TileDictionary)
if len(Word[:-1]) > 0:
Score +=GetScoreForWordAndPrefix(Word[:-1],
TileDictionary,AllowedWords)
return Score
36
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
Visual Basic
05 1 Sub Main() 12
Dim Again As Char = "y"
Dim Num As Integer
Dim Prime As Boolean
While Again = "y"
Console.Write("Enter a number: ")
Num = Console.ReadLine()
If Num > 1 Then
Prime = True
For Count = 2 To System.Math.Sqrt(Num)
If Num Mod Count = 0 Then
Prime = False
End If
Next
If Prime Then
Console.WriteLine("Is prime")
Else
Console.WriteLine("Is not prime")
End If
Else
Console.WriteLine("Not greater than 1")
End If
Console.Write("Again (y or n)? ")
Again = Console.ReadLine()
End While
End Sub
37
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
08 1 … 4
Do
Console.Write("Enter start hand size: ")
StartHandSize = Console.ReadLine()
Loop Until StartHandSize >= 1 And StartHandSize <= 20
…
38
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
TileDictionary
Console.WriteLine("Points for " & Tile.Key & ": "
& Tile.Value)
Next
Console.WriteLine()
CalculateFrequencies(AllowedWords)
End Sub
Alternative answer
Alternative answer
39
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
Alternative answer
40
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
C#
05 1 { 12
string Again = "Y";
int Num = 0;
bool Prime = true;
while (Again == "Y")
{
Console.Write("Enter a number: ");
Num = Convert.ToInt32(Console.ReadLine());
if (Num > 1)
{
for (int Count = 2; Count <
Convert.ToInt32(Math.Sqrt(Num)) + 1; Count++)
{
if (Num % Count == 0)
{
Prime = false;
}
}
if (Prime == true )
{
Console.WriteLine("Is prime");
}
else
{
Console.WriteLine("Is not prime");
}
}
else
{
Console.WriteLine("Not greater than 1");
}
Console.Write("Again (y or n)? ");
Again = Console.ReadLine().ToUpper();
}
}
41
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
else if (Value3.Contains(Count))
{
TileDictionary.Add((char)(65 + Count), 3);
}
else if (Value4.Contains(Count))
{
TileDictionary.Add((char)(65 + Count), 4);
}
else
{
TileDictionary.Add((char)(65 + Count), 5);
}
}
}
08 1 … 4
do
{
Console.Write("Enter start hand size: ");
StartHandSize = Convert.ToInt32(Console.ReadLine());
} while (StartHandSize < 1 || StartHandSize > 20);
…
42
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
Alternative answer
43
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
LetterCount = 0;
foreach (var Words in AllowedWords)
{
LetterCount = LetterCount +
(Words.Split(Letter).Length - 1);
}
Console.WriteLine(Letter + " " + LetterCount);
}
}
Alternative answer
44
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
{
return 0;
}
else
{
Score = 0;
if (CheckWordIsValid(Word, AllowedWords))
{
Score = Score + GetScoreForWord(Word,
TileDictionary);
}
Score = Score +
GetScoreForWordAndPrefix(Word.Remove(Word.Length - 1),
TileDictionary, AllowedWords);
return Score;
}
}
Alternative answer
45
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
Java
07 1 Map createTileDictionary() 2
{
Map<Character,Integer> tileDictionary = new
HashMap<Character,Integer>();
for (int count = 0; count < 26; count++)
{
switch (count) {
case 0:
case 4:
case 8:
case 13:
case 14:
case 17:
case 18:
case 19:
tileDictionary.put((char)(65 + count), 1);
break;
46
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
case 1:
case 2:
case 3:
case 6:
case 11:
case 12:
case 15:
case 20:
tileDictionary.put((char)(65 + count), 2);
break;
case 5:
case 7:
case 10:
case 21:
case 22:
case 24:
tileDictionary.put((char)(65 + count), 3);
break;
case 9:
case 23:
tileDictionary.put((char)(65 + count), 4);
break;
default:
tileDictionary.put((char)(65 + count), 5);
break;
}
}
return tileDictionary;
}
08 1 ... 4
do {
Console.println("Enter start hand size: ");
startHandSize = Integer.parseInt(Console.readLine());
} while (startHandSize < 1 || startHandSize > 20);
...
47
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
}
else
{
end = mid -1;
}
}
return validWord;
}
Alternative answer
48
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
{
letterCount = 0;
for(String word: allowedWords)
{
letterCount += word.split(letter + "").length
- 1;
}
Console.println(letter + ", Frequency: " +
letterCount);
}
}
Alternative answer
49
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
playerTiles,
Score playerScore, TileCount playerTilesPlayed,
Map tileDictionary,
String[] allowedWords)
{
playerTilesPlayed.numberOfTiles += word.length();
for(char letter : word.toCharArray())
{
playerTiles.playerTiles =
playerTiles.playerTiles.replaceFirst(letter+"", "");
}
playerScore.score += getScoreForWordAndPrefix(word,
tileDictionary, allowedWords);
}
Alternative answer
50
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
Pascal/Delphi
05 1 var 12
again : string;
num, count : integer;
prime : boolean;
begin
again := 'y';
while again = 'y' do
begin
write('Enter a number: ');
readln(num);
if num > 1 then
begin
prime := True;
for count := 2 to round(sqrt(num)) do
if num mod count = 0 then
prime := False;
if prime = true then
writeln('Is prime')
else
writeln('Is not prime');
end
else
writeln('Not greater than 1');
write('Again (y or n)? ');
readln(again);
end;
readln;
end.
51
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
08 1 … 4
StartHandSize := 0;
Choice := '';
while (StartHandSize < 1) or (StartHandSize > 20) do
begin
write('Enter start hand size: ');
readln(StartHandSize);
end;
…
52
MARK SCHEME – A-LEVEL COMPUTER SCIENCE – 7517/1 – JUNE 2018
end;
end;
53