2022algorithmics W
2022algorithmics W
2022
Letter
STUDENT NUMBER
ALGORITHMICS (HESS)
Written examination
Thursday 10 November 2022
Reading time: 3.00 pm to 3.15 pm (15 minutes)
Writing time: 3.15 pm to 5.15 pm (2 hours)
Structure of book
Section Number of Number of questions Number of
questions to be answered marks
A 20 20 20
B 13 13 80
Total 100
• Students are permitted to bring into the examination room: pens, pencils, highlighters, erasers,
sharpeners, rulers and one scientific calculator.
• Students are NOT permitted to bring into the examination room: blank sheets of paper and/or
correction fluid/tape.
Materials supplied
• Question and answer book of 29 pages
• Answer sheet for multiple-choice questions
Instructions
• Write your student number in the space provided above on this page.
• Check that your name and student number as printed on your answer sheet for multiple-choice
questions are correct, and sign your name in the space provided to verify this.
• All written responses must be in English.
At the end of the examination
• Place the answer sheet for multiple-choice questions inside the front cover of this book.
Students are NOT permitted to bring mobile phones and/or any other unauthorised electronic
devices into the examination room.
© VICTORIAN CURRICULUM AND ASSESSMENT AUTHORITY 2022
2022 ALGORITHMICS EXAM 2
n
aT knc if n 1
T (n) b where a > 0, b > 1, c ≥ 0, d ≥ 0, k > 0
d if n 1
Question 1
Container ships carry standard-sized shipping containers across the oceans. The containers are loaded in a
given order and unloaded in the reverse order at the destination.
Which one of the following abstract data types (ADT) is the most suitable for modelling this situation?
A. queue
B. stack
C. array
D. list
Question 2
Which one of the following is the signature for the ‘add a new element’ operation of an array?
A. element × array → array
B. element → array
C. array → array × element
D. array → element
Question 3
G is a connected, undirected graph with n vertices.
Therefore, G can have
n(n −1)
A. between n – 1 and edges.
2
n
B. between n – 1 and edges.
2
(n −1)
C. between n and edges.
2
n(n −1)
D. between and n(n – 1) edges.
2
SECTION A – continued
3 2022 ALGORITHMICS EXAM
Question 4
A year that is divisible by 4 is usually a leap year. The only exceptions to this rule are years that are divisible
by 100 but not divisible by 400.
A particular computer program stores year data as a four-digit integer. Let X, Y and Z be three Boolean
variables, where:
• X is ‘the year is divisible by 4’
• Y is ‘the year is divisible by 100’
• Z is ‘the year is divisible by 400’.
Which one of the following expressions evaluates to TRUE if a year is a leap year?
A. X AND Y AND Z
B. (X OR (NOT Y)) AND Z
C. (X AND (NOT Y)) OR Z
D. X AND (NOT Y) AND (NOT Z)
do not write in this area
3
Q R
2 5
P S 6
4 2 5
8
T U
Question 5
When Prim’s algorithm is run on G to find its minimal spanning tree, the order in which the algorithm visits
nodes could be
A. P, Q, R, S, T, U
B. R, Q, P, S, T, U
C. S, T, P, U, Q, R
D. T, S, P, Q, R, U
Question 6
Which one of the following is a shortest path from P to U ?
A. P, T, U
B. P, Q, S, U
C. P, Q, R, U
D. P, Q, S, T, U
SECTION A – continued
TURN OVER
2022 ALGORITHMICS EXAM 4
Question 7
Consider the following function.
Algorithm foo(n):
a 0
b 0
While (a < n) Do
a a + 3
b a - b
End
Return a – b
Question 8
Which one of the following algorithms would be suitable for determining which node in a graph is the most
important?
A. the Bellman-Ford algorithm
B. Dijkstra’s algorithm
C. the Floyd-Warshall algorithm
D. the PageRank algorithm
Question 9
The objective of the travelling salesman problem is to find the
A. lowest-cost tree that connects each node in the graph.
B. lowest-cost paths that connect each pair of nodes in the graph.
C. lowest-cost cycle that traverses every node of the graph exactly once.
D. lowest-cost cycle that traverses every edge of the graph exactly once.
SECTION A – continued
5 2022 ALGORITHMICS EXAM
Question 10
The diagram below shows part of the search tree created by the minimax algorithm for a particular problem.
Player A is the maximising player and Player B is the minimising player.
Player A
Player B
5 7 10 2 Player A
do not write in this area
The score that the algorithm would assign to the top node in the diagram is
A. 2
B. 5
C. 7
D. 10
Question 11
Which one of the following statements describes the divide step of the quicksort algorithm?
A. Divide the input list at its middle element to create two sub-lists.
B. Merge the two sorted sub-lists with the lower sub-list first.
C. Select an element from the input list. Create two sub-lists by dividing the input list into those values
lower than or equal to the element and those values higher than the element.
D. Divide the input list into a sorted sub-list and an unsorted sub-list.
SECTION A – continued
TURN OVER
2022 ALGORITHMICS EXAM 6
Question 12
Let T (n) be a function for the running time of fibonacci(n). For n ≤ 1, T (n) = O(1).
Question 13
Leah finds that this algorithm runs very slowly for n > 100.
It could be made to run significantly faster by
A. storing the results of recursive calls so that they can be re-used.
B. expanding the base case to include fibonacci(2)= 2, fibonacci(3)= 3 and
fibonacci(4)= 5.
C. combining the two base cases into a single If statement.
D. rewriting the last three lines of the algorithm as
Return fibonacci(n - 1) + fibonacci(n - 2).
Question 14
Algorithm A is known to be O(n3).
Which one of the following claims about Algorithm A could not be true?
A. Algorithm A is O(n2).
B. Algorithm A is Ω(n2).
C. Algorithm A is O(n4).
D. Algorithm A is Ω(n4).
SECTION A – continued
7 2022 ALGORITHMICS EXAM
Question 15
Consider the following recurrence relation.
n
2T n if n 1
T (n) 2
3 if n 1
The solution for T(n) using the Master Theorem is
A. O(n)
B. O(n log n)
C. O(n2)
D. O(n2 log n)
Question 16
do not write in this area
Question 17
Which one of the following methods can demonstrate that a computer can solve all computable problems?
A. Show that the computer can emulate a Turing machine.
B. Show that a Turing machine can emulate the computer.
C. Show that the computer can solve problems in the class NP-complete.
D. Show that the computer can solve problems in both the P and NP-complete classes.
Question 18
Which one of the following describes the method of a greedy heuristic algorithm?
A. Select a local optimum in each step in the hope of progressing towards a global optimum solution.
B. The problem is divided into smaller sub-problems and their solutions are combined to form the solution
to the original problem.
C. Generate candidates from the solution space in the hope of finding the global optimum solution.
D. Randomly select one option from several candidates in each step, hoping to eventually obtain a global
optimum solution.
Question 19
Which one of the following statements is incorrect?
A. NP-complete problems are the hardest problems in NP.
B. All problems in P are also in NP.
C. A proposed solution to a problem in NP can be checked in polynomial time.
D. All problems in NP are NP-complete.
SECTION A – continued
TURN OVER
2022 ALGORITHMICS EXAM 8
Question 20
Which one of the following statements is not true?
A. A complete graph can be acyclic.
B. If n ≥ 3, a graph with n vertices and at least n edges must be cyclic.
C. If n ≥ 3, a graph with n vertices must have at least n edges to be cyclic.
D. If an edge is added to a tree, the resulting graph will be cyclic.
END OF SECTION A
9 2022 ALGORITHMICS EXAM
SECTION B
n
aT knc if n 1
T (n) b where a > 0, b > 1, c ≥ 0, d ≥ 0, k > 0
d if n 1
O(nc ) if logb a c
c
and its solution T (n) O(n log n) if logb a c
O(nlogb a ) if logb a c
do not write in this area
Question 1 (2 marks)
Describe the process of the merge step of the mergesort algorithm when sorting in ascending order.
SECTION B – continued
TURN OVER
2022 ALGORITHMICS EXAM 10
b. The table below identifies species of birds in terms of their main colours and typical size.
rosella red 25 cm
wattlebird brown 35 cm
In the space provided below, draw a decision tree for identifying the birds shown in the table
above using colour as the first decision attribute. 4 marks
c. Let T be a decision tree for identifying birds and let x be a dictionary containing the
information about a particular bird. For each non-leaf node u in T, let P(u, x) be a function that
returns True if the decision at node u is true for a bird with parameters x and False otherwise.
Write pseudocode for an algorithm that traverses the decision tree to identify a bird based on
its features. 4 marks
do not write in this area
SECTION B – continued
TURN OVER
2022 ALGORITHMICS EXAM 12
Question 3 (8 marks)
Hamed and Kashvi are working on a research project to investigate the effect of including separate
bicycle lanes in selected streets of a Melbourne suburb. Including a bicycle lane in a street reduces
the space for cars. As a result, the cars will have to slow down. This will increase the time it takes
drivers to get where they need to go.
Hamed and Kashvi are going to create a simulation of the road network to investigate the effect of
introducing bicycle lanes on each road user. First, they will use a data structure to create several
road network models for different bicycle lane options. Then, they will use car trip data with each
road network model to understand how road users are affected by the different bicycle lane options.
a. What data structure could be used to represent the road network of the suburb for the
simulation, including the speeds that are possible on each road? Explain how the features of
the road network would be mapped to the data structure. 2 marks
The car trip data is going to be used to determine the number of people who are affected
by delays on certain roads.
Which of these data representations – Hamed’s or Kashvi’s – would be more suitable for
the simulation? Justify your answer. 2 marks
Write signature specifications for the following two operations of Trips. 2 marks
add:
totalTrips:
c. Many drivers wish to use the fastest route to their destination and will select their route based
on the road speeds at the time they depart.
What algorithm would be suitable for these drivers to use to determine their route before they
set off? Justify your answer. 2 marks
SECTION B – continued
TURN OVER
2022 ALGORITHMICS EXAM 14
ii. Explain why LB(r, g) = LB(r + 1, g − 2) after two green balls are picked. 1 mark
iii. Let redInPick(r, g) be a function that simulates a random pick of two balls from the bag
and returns the number of red balls obtained.
Write pseudocode for a recursive algorithm for LB(r, g). 6 marks
do not write in this area
SECTION B – continued
TURN OVER
2022 ALGORITHMICS EXAM 16
Question 5 (4 marks)
a. Describe how DNA computing overcomes the limitations of traditional sequential search
algorithms. 2 marks
b. Describe two limitations of DNA computing that have slowed its application to real-world
SECTION B – continued
17 2022 ALGORITHMICS EXAM
Question 6 (5 marks)
a. State the condition that Prim’s algorithm uses to select a new edge in each step of the
algorithm. 1 mark
SECTION B – continued
TURN OVER
2022 ALGORITHMICS EXAM 18
Question 7 (5 marks)
Rosa is solving the knapsack problem with the following items and a knapsack of size 10.
Initially, Rosa produces the search tree below to find the optimal solution.
s v s v s v s v s v s v
5 4 5 4 5 4 4 11 4 11 8 12
4 11 8 12 2 2 8 12 2 2 2 2
s v s v s v s v
5 4 5 4 5 4 4 11
4 11 4 11 8 12 8 12
8 12 2 2 2 2 2 2
s v
5 4
4 11
8 12
2 2
a. Write pseudocode for an algorithm that uses the following inputs and generates a search tree
in the same style as Rosa’s:
• a knapsack capacity, c
• a list of knapsack item sizes, sizes, where sizes[i] is the size of item i
• a list of knapsack item values, values, where values[i] is the value of item i 4 marks
do not write in this area
b. Rosa uses a backtracking algorithm to backtrack whenever she reaches a node that violates the
capacity limit of the knapsack.
Circle the nodes in the search tree on page 18 that would not be searched by Rosa’s algorithm
because it backtracks before reaching them. 1 mark
SECTION B – continued
TURN OVER
2022 ALGORITHMICS EXAM 20
Question 8 (4 marks)
Consider the following algorithm.
b. State the best case time complexity of this algorithm and outline the relationship between the
Value and the elements of List for this best case to occur. 2 marks
do not write in this area
SECTION B – continued
TURN OVER
2022 ALGORITHMICS EXAM 22
Question 9 (5 marks)
Philippe is implementing the Floyd-Warshall algorithm to find the transitive closure of a graph.
He stores the names of the nodes in the graph as a list called nodes. For each node in the graph,
he stores its edge data using a list of its adjacent nodes. These lists are stored in the dictionary
edges, where edges[u] is a list of the nodes adjacent to node u. Philippe plans to implement
the algorithm according to the following pseudocode.
# checks if nodes u and v are adjacent
Algorithm isAdjacent(nodes, edges, u, v):
Foreach value in edges[u] as neighbour Do
If neighbour = v Do
Return True
Return False
# implements Floyd-Warshall transitive closure
SECTION B – continued
TURN OVER
2022 ALGORITHMICS EXAM 24
Question 10 (2 marks)
Below is a partially complete instruction table for a Turing machine. This Turing machine is initialised to
start at the leftmost cell of data and in state A. For an input with an even number of 1s, the output string is
the same as the input string. For an input with an odd number of 1s, the output string has a 1 appended to the
string. For example, the inputs 0101 and 0111 generate the outputs 0101 and 01111 respectively.
State Blank 0 1
A X 0, right, A 1, right, B
B Y 0, right, B 1, right, A
halt
SECTION B – continued
25 2022 ALGORITHMICS EXAM
Question 11 (4 marks)
Jia is fascinated by maps and she wants to start a business that allows customers to send her maps
to colour and then print. Jia will artistically colour the maps using her favourite three colours of
green, gold and purple. No two adjacent regions of a map will have the same colour. She will
encourage customers to send maps with any number of regions and any arrangement.
a. Describe two problems with Jia’s idea. 2 marks
Problem 1
Problem 2
do not write in this area
b. Explain how Jia may overcome the two problems described in part a. in order to maintain as
much of her original idea as possible. 2 marks
Problem 1
Problem 2
SECTION B – continued
TURN OVER
2022 ALGORITHMICS EXAM 26
+18 –9 +5 +18 –9 –5
+18 –9 –5
+6 –12 –8 +10 +6 –12 +8 +10
–11 –4 +2 –1 +18 –9 –5
+6 –12 +8 +10
+3 +15 +1 +20 +19 –16 +7 –3
+11 +4 –2 +1
+3 +15 +1
ii. Explain how the flip operation would be performed within the data structure described in
part a.i. 3 marks
b. i. What features of this game indicate that a heuristic approach might be needed to achieve
do not write in this area
c. Kim is going to apply the simulated annealing meta-heuristic to the goal of this game.
i. Describe how she could generate a new candidate solution from a current solution. 1 mark
ii. Kim has correctly implemented the simulated annealing algorithm, but finds that it only
accepts candidate solutions that are improvements on the current solution.
Describe how she could modify the parameters of the algorithm to correct this issue. 1 mark
SECTION B – continued
TURN OVER
2022 ALGORITHMICS EXAM 28
Question 13 (9 marks)
Ishan is discussing what he has been learning in Algorithmics with Yan.
Ishan: ‘Hey Yan, today we learnt that it’s impossible to prove the correctness of mathematical
statements using computers.’
Yan: ‘What do you mean? My maths teacher showed me just the other day how to get my CAS
calculator to tell me whether an equation is true.’
a. How could Ishan refine his initial statement to Yan to better explain what he has learnt about
decidability and refute Yan’s counterexample? 3 marks
Ishan and Yan’s discussion continues and they talk about artificial intelligence (AI).
Yan: ‘Alan Turing must have believed in strong AI as he thought computers could play chess
and write poetry. Do you believe in strong AI?’
Ishan: ‘Not really. I think Searle’s Chinese Room Argument shows that strong AI is impossible.’
c. In the Chinese Room Argument, Searle describes a man in a room who has a book of
instructions that allows him to reply to messages he receives that are written in Chinese.
Explain how the Chinese Room Argument is used to argue against the possibility of strong AI. 2 marks
do not write in this area