2.1.1 and 2.1.3 - Algorithms + Answers
2.1.1 and 2.1.3 - Algorithms + Answers
Candidate Candidate
forename surname
INSTRUCTIONS TO CANDIDATES
• Write your name, centre number and candidate number in the boxes above. Please write clearly and in capital letters.
• Use black ink. HB pencil may be used for graphs and diagrams only.
• Answer all the questions, unless your teacher tells you otherwise.
• Read each question carefully. Make sure you know what you have to do before starting your answer.
• Where space is provided below the question, please write your answer there.
• You may use additional paper, or a specific Answer sheet if one is provided, but you must clearly show your candidate
number, centre number and question number(s).
Describe the steps that a linear search would take to find Anna in studentnames
Start at Rob
is Rob equal to anna
No so move to the next item anna
is Anna equal to Anna
yes so stop program
[4]
Complete the following diagram to show the stages an insertion sort would take to complete this task.
Each row represents one pass of the insertion sort algorithm. You may not need to use all empty rows.
[5]
Letter Definition
A Cleaning up data entered by removing non-standard characters
B Hiding or removing irrelevant details from a problem to reduce complexity
C Checking that the user is allowed to access the program
D Breaking a complex problem down into smaller problems
E Repeating elements of a program
F Converting one data type to another, for example converting an integer to a real number
Write the letter of the definition that matches each keyword in each space.
Decomposition ..................
Abstraction ..................
Casting ..................
[4]
State why the computer needs to translate the code before it is executed.
[1]
Describe two differences between how a compiler and an interpreter would translate the code.
[4]
4(a) A program creates usernames for a school. The first design of the program is shown in the flowchart in Fig. 2.
For example, using the process in Fig. 2, Tom Ward’s username would be TomWa.
State, using the process in Fig. 2, the username for Rebecca Ellis.
[1]
• If the person is a teacher, their username is the last 3 letters of their surname and then the first 2 letters of
their first name.
• If the person is a student, their username is the first 3 letters of their first name and then the first 2 letters of
their surname.
[1]
(ii) Write an algorithm for the updated program design shown in (i).
[6]
Parents must log in before they can use the system. They then choose to book a new appointment, view all
appointments already made or update their personal details. If parents choose to view their appointments, they
can either view them on-screen or print them off.
Each teacher has the assessment grades for each student. These grades are stored in numerical order.
2 3 4 5 6 7 8
Show the steps that a binary search would take to check whether the student has achieved a grade 7 in any
assessment.
2345678
2345678
678
7
[4]
(ii) Explain how a binary search would determine that a value does not appear in a given array.
Each car is given a star rating of 1 to 5, based on the age of the car and the number of miles it has been driven.
This rating is recorded in the computer system.
Removing detail to
understand a question better [1]
(ii) Give one example of how abstraction has been used in the design of this star rating system.
focus on age
[1]
(iii) Explain how authentication could be used as part of the defensive design considerations for this computer
system.
[2]
Show the stages of a bubble sort when applied to data shown in Fig. 3.
[4]
Show the stages of a binary search to find the word zebra using the data shown in Fig. 4.
AHKMORTWZ
AHKMORTWZ
RTWZ
RTWZ
Z
[4]
(ii) Give one example of how abstraction could be used when developing this program.
goal scores
OCR Land regularly emails discount codes to customers. Each discount code includes a check digit as the last
character.
(i) State one reason why a binary search would not be able to be used with this data.
not in order
[1]
(ii) Give the name of one searching algorithm that would be able to be used with this data.
For example, “Poetry from the War”, published in 2012 would be given the code POE12.
(i) Show the steps that a merge sort would take to put the following list of book codes into ascending
alphabetical order (from A to Z).
PBFJTAZH
PBFJ TAZH
PB FJ TA ZH
PBFJTASH
BP FJ AT HS
BFJP AHST
ABFHJPST
Faster
Better for larger lists
[2]
Show the stages of a bubble sort when applied to data shown in Fig. 3.
cbfvni
bcfvni
bcfnvi
bcfniv
bcfinv [4]
(b)
A second sample of data is shown in Fig. 4.
Show the stages of a binary search to find the word ‘zebra’ when applied to the data shown in Fig. 4.
[4]
1 a 1 mark per bullet to max 6 4 Answer must refer to this array, not a
generic description of linear search.
Access “Rob” / studentnames[0]… AO2 “Access first item” is NE for BP1 or BP3.
…does not equal “Anna” // not desired 1b(4) Must refer to this scenario.
item // move on
Access “Anna” / studentnames[1] Max 1 for “Compare ‘Anna’ to each item in
…does equal “Anna” // stop // item list” if nothing else credited.
found
b Anna inserted before Rob as first two 5 Rob Anna Huw Emma Patrice Iqbal
elements…
Anna Rob Huw Emma Patrice Iqbal
…Huw correctly inserted into sorted AO2
list… 1b(5) Anna Huw Rob Emma Patrice Iqbal
…Emma correctly inserted into sorted Anna Emma Huw Rob Patrice Iqbal
list …
Anna Emma Huw Patrice Rob Iqbal
…Patrice correctly inserted into sorted
list … Anna Emma Huw Iqbal Patrice Rob
…Iqbal correctly inserted into sorted
list and no further changes made. Sorted list highlighted
Total 9
2 1 mark for each letter 4 Accept answers that write the definition
instead of the letter.
AO1
Decomposition D 1a(4)
Abstraction B
Input Sanitisation A
Casting F
Total 4
b Compiler translates all the code in one 4 1 mark to be awarded for the correct
go… (AO1 1b) identification and one for a valid description
…whereas an interpreter translates up to a maximum of 4 marks.
one line at a time No more than 2 marks for answers relating
Compiler creates an executable… only to interpreters and no more than 2
…whereas an interpreter does marks for answers only relating to
not/executes one line at a time compilers.
Compiler reports errors at the end…
…whereas an interpreter stops when it
finds an error
Total 5
ii Taking firstname, surname and teacher 6 1 mark for each correct bullet to a
or student as input (AO3 2b) maximum of 6.
Checking IF role is teacher/student
(using appropriate selection) If used, a flowchart should represent the
For teacher ...Generating last 3 letters bulleted steps in the answer column.
of surname using appropriate string
manipulation
...Generating first 2 of letters of
firstname and adding to previous
For student.... correctly calculating as
before
Correct concatenation and output
e.g.
Ask the user to input the data, store in
variables firstname, surname and role.
Check whether the role entered is teacher.
If it is, join the right 3 most letters in
surname with the left 2 letters in firstname.
Store this in username.
If it is not teacher, join the left 3 letters from
firstname with the left 2 letters from
surname. Store this in username. Output
the value in username.
Total 8
5 i 1 mark per bullet, max 4 4 Do not accept generic answers that do not
refer to the data given.
Compare 5 (middle value) to 7
5 is smaller than 7 / 7 is larger than 7
so…
discard lower part of list / repeat with
upper part of list
…compare 7 to 7 (item found)
iii More efficient // Less time taken (to find 1 Accept reference to big O notation as
item) // fewer comparisons to make equivalent to more efficient.
(with large lists)
Total 7
iii Ensures only certain users can access 2 Allow other examples of authentication for
the system BP2
Using password / other example of
authentication technique
Total 4
e.g.
compare to wind
compare to zebra
Total 8
Total 3
Misconception
Total 2
10 i 1 mark per bullet, max 4. 4 Candidates can describe how the merge
sort would work rather than showing output
values at each stage.
List split into individual elements (may
be done over several steps or just as a Ignore intermediate steps.
starting point)
Merge individual elements into sorted Do not give final mark for simply showing
lists of size 2 the list sorted. Must have the (correct) idea
Merge lists of size 2 into sorted lists of of where it being merged from previous
size 4 lists.
Merge lists of size 4 into final sorted
list. Candidates’ answers describing / showing
other sorting algorithms (e.g. bubble sort,
insertion sort) are worth 0 marks.
Misconception
Exemplar 5
Total 6
11 a crim bait fright victor nym loose 4 1 mark for each row from row 2-5. Allow
e y ph multiple swaps in one stage, where it is
clear that a bubble sort has been applied.
bait crim fright victor nym loose
e y ph
bait crim fright nym victor loose
e ph y
bait crim fright nym loose victor
e ph y
bait crim fright loose nym victor
e ph y
e.g.
compare zebra to orange
compare to wind
compare to zebra
Total 8