Professional Documents
Culture Documents
AS-Chapter13.03-Handout-Arrays-MarkingScheme
AS-Chapter13.03-Handout-Arrays-MarkingScheme
FOR
CHAPTER 13.03
ARRAYS
Marking Scheme
© UCLES 2015 -2020
• INTEGER [1]
(b) (i)
x DayNumber OUTPUT
0 1
1 3 5/6/2015
2 5 7/6/2015
3 7 9/6/2015
Note: ‘x’ and ’output’ entries must be on or below the relevant ‘DayNumber’ entry
Mark as above [4]
(ii)
Tick Explanation (if invalid)
Cross
[3]
• Accept: all data items are of the same data type (1 mark) [max 2]
(ii) 24 [1]
(iii) • The total number of amplifiers ‘produced’ by workers 1, 2 and 3/three workers
(1 mark)
• on day 2 (1 mark) [2]
Page | 2
(b)
WorkerTotal
1 0
2 0
3 0
1 1 10
2 21
3 31
4 45
2 1 20
2 36
3 60
4 80
3 1 9
2 20
3 33
4 50
1 2.25
2 2
3 1.25 INVESTIGATE 3
[8]
Page | 3
(c) (i) WorkerNum : INTEGER (1 mark)
DayNum : INTEGER (1 mark)
WorkerTotal : ARRAY OF INTEGER
(1 mark) (1 mark)
WorkerAverage : REAL (1 mark) [max 4]
FOR WorkerNum ← 1 TO 3
WorkerTotal [WorkerNum] ← 0
ENDFOR
FOR WorkerNum ← 1 TO 3
FOR DayNum ← 1 TO 4
WorkerTotal[WorkerNum] ← WorkerTotal[WorkerNum] +
ProductionData[WorkerNum, DayNum]
ENDFOR
ENDFOR
FOR WorkerNum ← 1 TO 3
WorkerAverage = WorkerTotal[WorkerNum] / (4 *
DailyHoursWorked[WorkerNum]
IF WorkerAverage < 2
THEN
OUTPUT "Investigate" WorkerNum
ENDIF
ENDFOR
ENDPROCEDURE
Mark as follows:
All ‘3’s changed to NumWorkers
All ‘4’s changed to NumDays
WorkerAverage ‘4’ changed to NumDays [3]
Page | 4
Question Answer
OR
Lookup = []
For i in range(128) :
Lookup.append("")
Mark as follows:
Python:
One mark for Lookup and []
One mark for range(128)
ALTERNATIVE:
Page | 5
4
[6]
INPUT St artInd ex
INPUT Nu mberTo Ou t pu t 1
Or i gi nalCha r ← C H R( Index) 3
2 Ci p he rChar ← L oo k up[Index ] 4
5
OUP U T ("Inde x " & Index & ": Chara c te r " & Or i gi nalCha r &
" has s u bs titute c h aracter " & Ciphe rC h ar) 6
ENDFO R
1. Two IN PUT s at em en ts
2. W or ki ng lo op using In dex (allo w a lternati ve solution s inc lu ding se parat e l oo p count er)
3. Assign ment ( using co rr ect va lues of Index o r o ther variabl e)
4. Assign ment ( using co rr ect va lues of Index o r o ther variabl e)
5. O ne m ark for O UTPU T of a string c ombi ning text and va ria bles...
6. ...a seco nd mark if O UT P UT st rin g i s com plet ely co rr ect
Python
Page | 6
Question Answer Marks
BurnFlag ← FALSE
FOR i ← 1 TO 8
FOR j ← 1 TO 8
OldPixelValue ← Picture[i, j]
PixelTemp ← OldPixelValue * 1.1
NewPixelValue ← INT(PixelTemp)
IF NewPixelValue >= 255
THEN
NewPixelValue ← 255
BurnFlag ← TRUE
ENDIF
Picture[i, j] ← NewPixelValue
ENDFOR
ENDFOR
RETURN BurnFlag
ENDFUNCTION
Page | 7
Question Answer Marks
6 'Pseudocode' solution included here for development and clarification of mark Max7
scheme.
Programming language solutions appear in the Appendix.
FUNCTION ProcessMarks(Mark: ARRAY[1:20] OF INTEGER)
RETURNS INTEGER
DECLARE Highest : INTEGER
DECLARE Average as REAL
DECLARE Total as INTEGER
DECLARE Position as INTEGER
Total ← 0
Highest ← Mark[1] //The highest mark is the first one
Position ← 1
FOR i ← 1 to 20
Total ← Total + Mark[i]
IF Mark[i] > Highest
THEN
Highest ← Mark[i]
Position ← i
ENDIF
ENDFOR
Average ← Total/20
Output ("The average mark is " & Average & " and
the highest mark is " & Highest)
RETURN Position
ENDFUNCTION
1 mark for each of the following:
Page | 8
Question Answer Marks
Page | 9
Question Answer Marks
Page | 10
Question Answer Marks
ENDPROCEDURE
PROCEDURE Flip()
//Use of temproary row (8 elements)
FOR i ← 1 to 5
FOR j ← 1 to 8
temp[j] ← Picture[i, 9 – j] //temp is row i
reversed
ENDFOR
FOR j ← 1 to 8
Picture[i,j] ← temp[j] //copy temp back to row i
ENDFOR
ENDFOR
ENDPROCEDURE
Page | 11
Question Answer Marks
FOR i ← 1 to 5
FOR j ← 1 to 8
NewPic[i, 9 - j] ← Picture[i, j] //NewPic row
is Pic row flipped
ENDFOR
ENDFOR
END PROCEDURE
Page | 12
9 608/23 Cambridg e Internati onal AS/A L evel – Mark Scheme Ma y/June 201 8
PUBLISHED
Answe r
Question Marks
9 9
Page | 13
Question Answer Marks
ClipFlag ← FALSE
FOR i ← 1 TO 8
FOR j ← 1 TO 8
IF Picture[i, j] > MaxVal
THEN
Picture[i, j] ← MaxVal
ClipFlag ← TRUE
ENDIF
ENDFOR
ENDFOR
RETURN ClipFlag
ENDFUNCTION
Page | 14
Question Answer Marks
11(a) TotalValue ← 0 7
ZeroCount ← 0
1 Both initialisations
2 Loop 100 times
3 Adding individual element to TotalValue in a loop
4 Check if element value is zero in a loop
5 If so increment ZeroCount in a loop
6 Average is calculated after the loop
7 Both OUTPUT statements, including message and variables
Page | 15
Question Answer Marks
1 Array declaration
2 Additional local variable
3 Nested loops
4 Array element assignment within the inner loop
Page | 16
Question Answer Marks
13 6
Mark as follows:
Page | 17
Question Answer Marks
Page | 18
Question Answer Marks
Note:
Credit alternative solutions for forming and checking a single output string
Page | 19
9608/21 Cambridge International AS & A Level – Mark Scheme May/June 2020
PUBLISHED
17(b) Description: 4
•uses a flag variable to stop the outer loop
•after no more swaps made during one pass of the inner loop
•the flag is reset before the inner loop starts, and set whenever a swap is
made
•decreases the loop size at end of inner loop (Boundary decremented)
Effective because:
•It prevents unnecessary iterations / passes through the array (i.e. when
the array is already sorted) // terminates the algorithm when all elements
are in order // reduces the number of unnecessary comparisons
Page | 20
Question Answer Marks
Alternative Solution:
Mark as follows:
1 SET Index to 1
2 SELECT the character from input parameter string at Index position
3 IF character is colon then go to 5
4 Else INCREMENT Index and repeat from 2
5 Extract a substring from the left of the parameter string (and assign this to
variable Name)
6 ...Using Index -1 for the length
7 RETURN Name
Note:
Mark points may be combined for equivalent marks
e.g a suitable structured English description of the pseudocode statement
below satisfies MP 5, 6 and 7:
18(b)(i) Description: 4
Page | 21
Question Answer Marks
18(b)(ii) 'Pseudocode' solution included here for development and clarification of mark 8
scheme.
Programming language example solutions appear in the Appendix.
PROCEDURE BubbleSort()
DECLARE Temp : STRING
DECLARE NoSwaps : BOOLEAN
DECLARE Boundary, J : INTEGER
Boundary ← 999
REPEAT
NoSwaps ← TRUE
FOR J ← 1 TO Boundary
IF Contact[J] > Contact[J+1]
THEN
Temp ← Contact[J]
Contact[J] ← Contact[J+1]
Contact[J+1] ← Temp
NoSwaps ← FALSE
ENDIF
ENDFOR
Boundary ← Boundary - 1
UNTIL NoSwaps = TRUE
ENDPROCEDURE
Mark as follows:
def BubbleSort()
# Temp : String
# NoSwaps : Boolean
# Boundary, J : Integer
Boundary = 999
NoSwaps = TRUE
Boundary = Boundary - 1
Page | 22
Question Answer Marks
ENDFOR
Alternative
1 Initialisation of Count
2 FOR loop
3 Check column 1 element and increment count
4 Check column 2 element and increment count // nested loops
5 OUTPUT Count together with suitable mesage
Page | 23
Question Answer Marks
19(a) 'Pseudocode' solution included here for development and clarification of mark 5
scheme.
Programming language example solutions appear in the Appendix.
FUNCTION Extract(InString : STRING) RETURNS STRING
DECLARE Name : STRING
DECLARE NextChar : CHAR
DECLARE Index : INTEGER
CONSTANT COLON = ':'
Index ← 1
Name ← ""
NextChar ← LEFT(InString, 1)
RETURN Name
ENDFUNCTION
Alternative:
ENDFUNCTION
Mark as follows:
1 Function heading and ending (where required) including parameters
2 Extract (next) character from InString
3 Conditional loop while character is not colon
4 Append character to Name and increment Index in a loop //
calculate substring length and use LEFT() after loop
5 RETURN Name (may be combined with alternative mp 4)
Page | 24
Question Answer Marks
Alternative #1
Header:
PROCEDURE Extract (BYREF Name : STRING, BYREF Email :
STRING, BYVALUE DataItem : STRING)
Explanation:
Could additionally pass the name and email address to the procedure
using BYREF. Procedure would extract name and email and assign
values to BYREF parameters; these would then be available to
calling program.
Alternative #2
Header:
PROCEDURE Extract (DataItem : STRING)
Explanation:
Declare new global variables for the name and email address. These
could be assigned values within the new procedure and these values
would be used by the calling program.
Mark as follows:
Two marks for header – must be a Procedure not a Function (but
see note below)
Max Two marks for explanation
Note:
Allow solution based on user-defined record type / record item returned
from modified function.
Max 3
def Extract(InString)
# Name : String
# NextChar : Char
# Index : Integer
COLON = ':'
Index = 1
Name = ""
NextChar = InString[1:2]
Return Name
Page | 25