Professional Documents
Culture Documents
Monash University
SOLUTIONS
STUDENT ID _________________
During the test, you must not have in your possession, a book, notes, paper, electronic device/s,
calculator, pencil case, mobile phone or other material/item which have not been authorised for the
test or specifically permitted as noted below. Any material or item on your desk, chair or person will
be deemed to be in your possession. You are reminded that possesion of unauthorised materials in
an exam is a discipline offense under Monash Statute 4.1
2
AUTHORISED MATERIALS
3
CALCULATORS!! ! ! ! NO
4
OPEN BOOK! ! ! ! ! NO 5
6
SPECIFICALLY PERMITTED ITEMS! NO
Total
! !
Page 1 of 6
Downloaded by Alan Kafaei (kafaeialireza@gmail.com)
lOMoARcPSD|4755966
Question 1 [1 + 2 + 2 = 5 Marks]
(a) By marking vertices and edges, draw a spanning tree in the following graph
An Eulerian circuit in G is a trail in G which starts and end at the same vertex and contains
every edge in G exactly once.
! !
Page 2 of 6
Downloaded by Alan Kafaei (kafaeialireza@gmail.com)
lOMoARcPSD|4755966
Question 2 [5 Marks]
10, 8, 2, 7, 6, 9
Using the Insertion Sort algorithm sort the list into increasing order. You should write the
list in the table below after each iteration of the main loop of this algorithm.
10 8 2 7 6 9
8 10 2 7 6 9
2 8 10 7 6 9
2 7 8 10 6 9
2 6 7 8 10 9
2 6 7 8 9 10
! !
Page 3 of 6
Downloaded by Alan Kafaei (kafaeialireza@gmail.com)
lOMoARcPSD|4755966
Question 4 [6 marks]
A palindrome is a word which is spelt the same ways forwards as backwards. For
example, abba is a palindrome but abbbaba is not.
Write a Python program that given a string, aString, prints true if aString is a palindrome,
and false otherwise.
You can assume that aString has been given and you do not need to write code to read a
string from a file or ask a user to input a string.
n = len(aString)
result = True
if n > 1:
for k in range(n//2):
if aString[k] != aString[n-k-1]:
result = False
print(result)
! !
Page 5 of 6
Downloaded by Alan Kafaei (kafaeialireza@gmail.com)
lOMoARcPSD|4755966
Question 5 [2 + 2 = 4 marks]
For the following fragments of Python code, write what would be printed.
(a)
aList = [1, 2, 3, 4]
for k in range(len(aList)):
print(aList[len(aList)-k-1)])
4
3
2
1
(b)
aStr = “Reverse“
for k in range(-1, -len(aStr), -1):
print(aStr[k])
e
s
r
e
v
e
! Page 6!of 6
End of Test
Downloaded by Alan Kafaei (kafaeialireza@gmail.com)