Computer Science Mock Marking Scheme
Computer Science Mock Marking Scheme
CǞǠǝǘǙȨǛ SȰǤȨǟȰȨ
HIGHER & ORDINARY LEVEL
MARKING SCHEME
Pre-Leaving Certificate Examination 2024
Section A 45 marks
Question 1
Please study the code carefully and then answer the following question: Given the following six
lines of code from a program, for each line, fill in the value stored in the variable answer.
1 answer = 7
2 name = “Robin”
3 answer += 1
4 name = answer
5 answer = “Charlie”
6 answer = name
answer = 7 7
name =”Robin” 7
answer += 1 8
name = answer 8
answer = name 8
Question 2
Briefly describe one problem that can be solved using heuristics and why it needed a heuristic
approach to be solved.
Sample Answer, not required, red components are the marking scheme.
Consider yourself a salesperson that must visit multiple places before returning home. You must
determine the fastest path in order to save time and money. The “Travelling Salesman Problem” (TSP)
is an example of this problem and it is heuristic. Because there are so many potential routes to take
when there are several cities to visit, it is necessary to use a heuristic technique because doing so
would take a long time.
Heuristic methods are intelligent ways that quickly identify a reasonably short route, even if it isn’t
really the shortest route possible. When there are numerous cities to visit, these techniques are
crucial for effectively resolving TSP and difficulties of a similar nature. Sat navigation could have also
been used.
Question 3
The following code was intended to replace any negative numbers in a list with the value 0.
However, the above code does not work as intended, printing out the result: [1, 2, 3, 4, -5, 6]
The reason for this issue/bug is that item is a variable assigned for the loop iterations (for loop).
Each list item is copied into this variable (item), and when a <0 value is identified it is then modified.
However, the variable item is modified and not the actual list. When you then print the list the same
values are presented.
2 marks for mentioning the variable item (Fair description - limited understanding = 1 mark)
3 marks for why this occurred, as in the variable was assigned the change, and not the
element in the list (Fair description - limited understanding = 1 mark)
Question 4
Testing is used in software development. The below code was intended to replace any negative
numbers in a list with the value 0, but instead it outputs [1, 2, 3, 4, -5, 6], not changing the
negative values as intended.
Explain how you might test the above code to identify the errors in the program.
Mention an appropriate test, for example, use case or even a unit test (you can ignore if they leave
out it should be a function). 2 marks
Question 5
Describe what a unit test is, and how it differs from a system test.
Individual components or modules of a software program are verified separately during a unit test. A
unit test’s objective is to verify that each module or component of the software performs as intended.
The smallest tested component of the code, such as a function, is referred to as a “unit” in this
context. These are more often than not automated.
3 marks must include small unit and automated
(Fair description - limited understanding = 1 mark)
System tests, on the other hand, evaluate the behaviour of the entire software system as a whole.
These tests verify that all the components of the system work together correctly to deliver the
expected functionality.
2 marks must include user and overall system
(Fair description - limited understanding = 1 mark)
Question 6
The list below contains 100,000 integers. Only the first six items in the list are shown.
(a) Why would you not present the data in the above form to someone that wants to find the
number of items in the list that are negative?
Data in the above format as above is not readable by humans, for example, if you were to see how
many negative numbers in the 100,000 in a file you would not be able to, it would be too hard for
humans to read.
(b) Name one graphical form that would be suitable for presenting the data in the list, and
one graphical form that would be unsuitable and why (for each form).
Question 7
Insertion sort
(b) What is the time complexity for the worst-case scenario for this algorithm?
O(n²)
Question 8
Agent based modelling can be used to mimic and understand how traffic works in cities. In this case,
every car or person is like a little computer character with its own traits and actions. These characters
can talk to each other and react to things like traffic lights, road closures, and anything else that can
make traffic better or worse.
(b) Explain the benefits of using agent-based modelling for your example named above.
Agent-based modelling allows users to gain insights into traffic congestion, the impact of new road
infrastructure, and strategies for optimising traffic management.
Question 9
Year_
ID FName SName
Tutor_ID
1 3 Charlie Quille
2 2 Robin Quille
Students
Table 1 represents teachers and tutors, table 2 represents students. Each table has a primary key.
2 marks description of each table – could be part of overall answer
(Fair description - limited understanding = 1 mark)
Table 1 to table 2 are relational, that is, a year tutor is related to/has students. This is represented by
the foreign key field “Year_Tutor_ID”, for example, Robin Quille has Roisin Faherty as her year tutor.
3 marks linking primary and foreign keys to describe one to many relationship – does not need
to include the words one to many (Fair description - limited understanding = 1 mark)
Question 10
Below is an extract from a US National Cancer Institute post titled 'Can Artificial Intelligence
Help See Cancer in New, and Better, Ways?' (2022). Read the extract carefully and answer the
questionthat follows.
“Two identical black-and-white pictures of murky shapes sit side-by-side on a computer screen.
On the left side, Ismail Baris Turkbey, M.D., a radiologist with 15 years of experience, has
outlined anarea where the fuzzy shapes represent what he believes is a creeping, growing
prostate cancer. On the other side of the screen, an artificial intelligence (AI) computer program
has done the same —and the results are nearly identical.”
Name and describe one ethical consideration and proposed action that you think should be
applied if we are to use AI in the medical domain for predicting cancer.
When we use AI to predict cancer in medicine, we need to worry about two important things (any one
discussion is okay):
Reliability: We want the AI to be good at making predictions, so it doesn’t give the wrong diagnosis or
advice.
Fairness: The AI should treat everyone the same way. If it’s biased and gives different results to
different groups of people, it can create unfair healthcare differences.
2 marks any reasonable ethical issue (Fair description - limited understanding = 1 mark)
One proposed action is to always have humans on the loop, that is, for every prediction there should
be some human oversight to ensure fairness and reliability.
3 must be related to the ethical consideration (Fair description - limited understanding = 1 mark)
Question 11
Websites are typically not as adaptive as they should be to allow for inclusive use for users with
special/additional needs. Name and describe two elements or design features that you would
implement in a website to support users with additional needs.
Text to speech and speech to text: Functionality can be a huge help to users who have hearing or
vision problems. TTS technology speaks aloud the website’s text content so that users who are blind
can access and comprehend the content. STT, on the other hand, transforms spoken words into
written text, making it possible for people with hearing loss to utilise the website.
3 marks any reasonable element/design feature
(Fair description - limited understanding = 1 mark)
A website will adjust to different devices and user needs if it has a responsive and accessible design.
Users who utilise assistive devices or who have cognitive or mobility problems must understand
this. To accommodate various screen sizes and input methods (mouse, keyboard, touch, and voice),
elements should be correctly scaled, spaced, and arranged.
2 marks any reasonable element/design feature
(Fair description - limited understanding = 1 mark)
Question 12
The below code uses the mean function from the statistics module to find the mean in a list:
myList = [1, 2, 3, 4, 5]
median = statistics.mean(myList)
print(median)
Pattern recognition is the ability to recognise common approaches (such as code) or patterns
within problems you are trying to solve. When you break down (decompose) a problem into
smaller subproblems, you may be able to spot patterns/previous code approaches that will help
you to solve the problem. – adopted from Isaac Computer Science.
Identify one pattern and explain its use if you were to write the code for the statistics.mean
function yourself:
One pattern that would be used to solve this problem to get the mean is a loop to add up all of the
values.
This loop allows us to get the total of all the numbers in the list (a key component of getting the mean).
3 marks any of the two patterns (Fair description - limited understanding = 1 mark)
2 marks explain its role (Fair description - limited understanding = 1 mark)
A recursive algorithm breaks down a complicated problem into smaller, related problems and solves
each of them in a similar fashion.
3 marks for mentioning smaller parts (Fair description - limited understanding = 1 mark)
4 marks for mentioning smaller parts are similar and overall definition
(Fair description - limited understanding = 2 marks)
(b) Recursion is slower computationally than solving the same problem using a loop, yet
recursion is often the preferred method over a loop for some algorithms such as the
quicksort algorithm, why is this the case?
(c) Below is an example of a recursive function for the quicksort algorithm. This algorithm
sorts a list in ascending order. Modify the code to sort the list in descending order. The
first four rows are completed where no modifications were needed.
Modified code – leave blank if
Original code
modification is not needed.
def qS(listIn): -
if len(listIn) > 1: -
pivot = listIn[-1] -
belowPiv =[] -
for item in listIn[:-1]: -
if item < pivot: If item > pivot
belowPiv.append(item) -
abovePiv =[] -
for item in listIn[:-1]: -
if item > pivot: If item < pivot
abovePiv.append(item) -
return qS(belowPiv) + [pivot] +
-
qS(abovePiv)
else: -
return(listIn) -
(a) The internet allows the world wide web to run on it. This happens in part due to
communication protocols. One such set of protocols that is widely used is TCP/IP.
Explain what TCP is in the transport layer in the TCP/IP protocol stack.
TCP is a standard communication protocol that ensures the reliable and ordered delivery of data
between devices on a network. It establishes a connection before data transfer, manages the flow of
data, and performs error checking to ensure that the information sent from one device is received
accurately by the destination device. TCP is part of the TCP/IP protocol suite, which forms the basis
for communication on the internet.
(b) IP addresses are used in the internet layer of the TCP/IP protocol stack. The following is
an example of an IP address:
192.168.0.1
(i) What is an IP address?
(ii) As the number of devices connected to the internet grows, identify one issue that
could arise with an IPv4 address as shown above?
An IP address is like a digital ID for devices on the internet, helping them talk to each other. The worry
with IPv4 addresses is that there aren’t enough of them for all the new gadgets we’re connecting.
That’s why there’s a switch to IPv6, which has a lot more addresses, making sure everything stays
connected as we add more devices to the internet.
(c) An IP address is often used when cybercrime is investigated. This is part of the TCP/IP
stack. How can an IP address be used in cybercrime investigations?
When investigators are trying to catch cybercriminals, they use something called an IP address. It’s
like a digital ID for devices on the internet. In the tech world, it’s part of the TCP/IP stack, and it helps
figure out where online activities are coming from and going to. So, if someone’s up to no good
online, the investigators can use the IP address to track them down and find out who they are and
where they’re doing their activities.
(d) Interactive information systems are often implemented as a client server model. With
respect to data security, why is a client server model a good choice?
For interactive information systems, using a client-server model is a wise decision for data security
because it comes with a number of benefits:
• It enables unified management of security and makes it simpler to enact regulations and safety
measures.
• Access Control: The server can limit who has access to data, ensuring that only people with
permission can access it.
• Data exchanged between clients and servers can be encrypted to ensure its security while in transit.
• User Verification: Servers can verify a user’s identity and determine if they are authorized to view a
certain piece of data.
• Logging: Servers can preserve thorough records of user behavior that can be used to track and look
into security concerns.
(a) What is the difference between raw data and data transformed for analysis?
Raw data
Unorganised and unprocessed data is referred to as “raw data.” It is the most fundamental type of
data and is meaningless on its own. Various formats for raw data exist, including those for numbers,
text, pictures, and other data types. Examples of raw data include a list of numbers, a collection of
sensor readings, or a string of characters and words in a text file.
2 marks (Fair description - limited understanding = 1 mark)
Transformed data
Raw data is made usable and valuable for decision-making, comprehension, or communication by
providing context, relevance, and structure. In order to make information easier to understand and
use, it is frequently transformed, this may include, fixing problematic data, taking the raw data and
calculating frequencies of occurrence for a bar chat etc.
2 marks, should include one example of transformed data (Fair description - limited
understanding = 1 mark)
(b) The World AnƟ-Doping Agency (WADA) state that “Blood doping is the misuse of certain
techniques and/or substances to increase one’s red blood cell mass, which allows the body
to transport more oxygen to muscles and therefore increase stamina and performance.”
Each year, athletes are tested for increased red blood cells, where the data presented in the
following histogram shows the red blood cell count on the X axis and the number of athletes
on the Y axis.
Do you think that some athletes were blood doping? Analyse the histogram and available
data (mean, mode and median) to support your answer.
There is likely some blood doping going on. The graph is mostly symmetrical (normal distribution) as
the mean, mode and median are similar (students do not need to prove this). There are a group 1-3
people who have a distinctly different red blood cell count, outside of this distribution, and they have
a red blood cell count of ~ 6.5.
(c) WADA would like you to develop an algorithm that automatically detects if blood doping
occurs based on red blood cell count. By examining the histogram in the Figure from part
b of this question, write an algorithm in pseudocode that will detect athletes are blood
doping assuming that the red blood cell counts are stored in a list such as the one below
(note: the data is in a one dimensional list, call athletes_RBCB that you can reference):
List example:
athletes_RBCB = [4,5.6,4.2, 6.6, 6.4, 4,1]
Hint: Loop through the list and write the pseudo code to identify any possible values that may have
blood doped.
(d) False predictions are often made by such algorithms. A False Positive (FP) is where an
athlete that is predicted as blood doping but did not, and a False Negative (FN) is where an
athlete is predicted as not blood doping but was.
Briefly describe, basing your answer on ethics, which of the above predictions (a False
Positive or a False Negative) is worse for the WADA.
The least desirable error for the World Anti-Doping Agency (WADA) would be a False Negative (FN).
A False Negative happens when an athlete is expected to not be blood doping but is actually blood
doping in the context of WADA’s aim to detect and prohibit doping in sports. False Negatives are
typically viewed as more harmful in the context of anti-doping efforts because they allow doping to
go undetected and undermine the fundamental principles of fair play in sports. False Positives (FPs)
are also problematic because they can unjustly damage an athlete’s reputation, trigger investigations,
and potentially harm their career.
(a) Surveys are common practice, and analysis of such surveys is often essential to gain an
understanding of data collected, transforming it into information. This survey was data
collected by asking people the county they were from and their monthly rent. This was to
determine national and country average rent rates. This survey only included people from
Dublin, Kildare and Laois.
Open the program called Question16_A.py from your device.
Enter your name on line 2.
# Enter name:
rent = [2500, 1200, 2000, 2100, 1900, 1999, 1790, 1500, 1000, 1390, 1980,
1105, 1999]
# Part i
# Part ii
print(“-”*18)
print(“{:<12}”.format(“County”)+”{:<12}”.format(“Rent €”))
print(“-”*18)
for index in range(len(county)):
print(“{:<12}”.format(county[index])+”{:<12}”.format(rent[index]))
# Part iii
# Part iv
This way the data is stored is that each index (0, 1, 2 …) in each of the two lists (county and
rent) holds corresponding data. That is the first element of each list is a response from the
same person. The list county records their county and the list rent records how much their
monthly rent is. For any analysis in this question, you must assume that the lists could be
larger, so you must calculate all values using code, they must not be hard coded.
The program currently loops through the list and prints to the screen each survey response:
----------------------------
County Rent €
----------------------------
Dublin 2500
Laois 1200
Dublin 2000
(i) Where Part i is a comment in the code, write code to calculate and print the total number
of survey responses that the study has collected. When the program is run, it may look as
follows:
The total people in the survey is: 13
(ii) Where Part ii is a comment in the code, write code to take in and store another survey
response from the user, you must take in their county name and monthly rent and
add them to the appropriate lists. You can assume that the user will always enter one of
the following counties (in the correct case, that is, first letter uppercase and the rest lower
case) Dublin, Kildare and Laois. When the program is run, it may look as follows:
county.append(surveyCounty)
rent.append(surveyRent)
10 marks (3 marks for each entry and variable type, and 2 marks each for appending to
the correct lists)
(iii) Where Part iii is a comment in the code, write code to calculate and print the average rent
across all three counties (rounding to two decimal places).
10 marks (6 marks for calculating the average rent, 4 marks for printing)
(iv) Where Part iv is a comment in the code, write code to calculate and print the average rent
for each of the three counties Dublin, Kildare and Laois (rounding to two decimal places).
When the program is run, it may look as follows:
dublinRents = []
kildareRents = []
laoisRents = []
if county[index] == “Kildare”:
kildareRents.append(rent[index])
if county[index] == “Laois”:
laoisRents.append(rent[index])
print(“\n”)
# Dublin
averageRentDublin = sum(dublinRents) / len(dublinRents)
print(“Average Rent for Dublin: €”, round(averageRentDublin,2))
# Kildare
averageRentKildare = sum(kildareRents) / len(kildareRents)
print(“Average Rent for Kildare: €”, round(averageRentKildare,2))
# Laois
averageRentLaois = sum(laoisRents) / len(laoisRents)
print(“Average Rent for Laois: €”, round(averageRentLaois,2))
21 marks (7 marks per average broken into: 4 marks for getting totals, 2 marks for
calculating the average (using length in this example) and 1 mark for printing)
Note: this was one example of determining the average rent for each of the three
counties, other methods applicable, 7 marks per county applies.
(b) The infinite monkey theorem states that a monkey hitting keys at random on a typewriter
keyboard for an infinite amount of time will almost surely type any given text, including
the complete works of William Shakespeare.
Open the program called Question16_B.py from your device.
Enter your name on line 2.
# Enter name:
import random
targetWord = “T”
def monkeys_typing():
guessNumber = random.randint(65, 90)
letter1 = chr(guessNumber)
count = 1
guess = letter1
print(guess)
print(monkeys_typing())
This monkeys_typing function is designed to return the number of times it takes a monkey
to guess characters (mimicking the infinite monkey theorem for a limited amount of text)
until it guesses the letter T. Please note the random number guesses the ASCII range for
upper case letters, and converts them to characters to compare against the desired
output, the letter T.
(i) For this part, do not modify the function, modify the main body code to run the function
three times and get an average of how many guesses are needed to type the letter T. An
example output would be:
run1 = monkeys_typing()
run2 = monkeys_typing()
run3 = monkeys_typing()
average = (run1+run2+run3) / 3
print(“Average number of guesses for three runs are:”, average)
(ii) Modify the function to identify how many guess it may take to generate the word “THE”,
note you will also have to modify the variable: targetWord = “THE”. An example output
would be:
import random
targetWord = “THE”
def monkeys_typing():
guessNumber = random.randint(65, 90)
letter1 = chr(guessNumber)
guessNumber = random.randint(65, 90)
letter2 = chr(guessNumber)
guessNumber = random.randint(65, 90)
letter3 = chr(guessNumber)
count = 1
guess = letter1+letter2+letter3
print(guess)
return count
run1 = monkeys_typing()
run2 = monkeys_typing()
run3 = monkeys_typing()
average = (run1+run2+run3) / 3
print(“Average number of guesses for three runs are:”, average)
20 marks (10 for the three guesses, 10 for combining and comparing).