首页 >
> 详细

COMP20007 Design of Algorithms, Semester 1, Mid-Semester Practice Test, 2022

School of Computing and Information Systems

COMP20007 Design of Algorithms

Semester 1, 2022

Sample Mid Semester Test

Instructions to Students

• The total time to read, complete, scan and upload your solutions to this test is 1 hour. You have to

allow at least 15 minutes to scan and upload your solutions.

• You must submit your solutions by 11:00 AM AEST.

• Late submissions will be subject to a 10% penalty per 5 minutes late and submissions after 11:20

AM AEST will not be marked.

• This test contains 4 questions which will be marked out of 10 marks.

• The test is open book, which means you may only use course materials provided via the LMS or

the text book but must not use any other resource including the Internet.

• You must not communicate with other students or make use of the Internet.

• Solutions must be written on separate pieces of paper with pen or pencil. You must write your

solution to each question on a new sheet of paper and clearly indicate which question you are

answering on each page.

• You must not use a tablet to complete this test.

• You must also indicate which question is answered on which page via Gradescope.

• You must use a Scanner app on your smartphone to scan your solutions, email them to your laptop

and then submit a PDF file to Gradescope via Canvas.

• A Gradescope guide to scanning your test can be found here: https://gradescope-static-assets.

s3-us-west-2.amazonaws.com/help/submitting_hw_guide.pdf

• The Dropbox and Microsoft OneDrive mobile apps also have scanning capabilities.

Page 1 of 5

COMP20007 Design of Algorithms, Semester 1, Mid-Semester Practice Test, 2022

Question 1 [2 Marks]

We know, from lectures, the following facts. For 0 < ε < 1 < c,

1 ≺ logn ≺ n

ε ≺ n

c ≺ n

logn ≺ c

n ≺ n

n

,

where f(n) ≺ g(n) means both f(n) ∈ O(g(n)) and g(n) 6∈ O(f(n)) (i.e. g(n) is not in O(f(n))).

For the following pairs of functions, f(n),g(n), determine if f(n) ∈ Θ(g(n)), f(n) ∈ O(g(n)), or f(n) ∈

Ω(g(n)), making the strongest statement possible. That is, if both f(n) ∈ O(g(n)) and f(n) ∈ Ω(g(n))

are true, you must answer with the form f(n) ∈ Θ(g(n)). You must answer with f(n) on the left and

g(n) on the right, for example, you may not answer g(n) ∈ O(f(n)).

You must show all working. A correct answer that does not show your working will result in 0 marks.

COMP20007 Design of Algorithms, Semester 1, Mid-Semester Practice Test, 2022

Question 2 [2 Marks]

A string of characters is called a palindrome if reading the characters from left to right gives the same

sequence as reading the characters from right to left.

For example: abccba, ahgiigha and abgllggllgba are all palindromes while abcdabcd, lghddgl and

abcd are not.

Write the pseudocode for an algorithm which, given a string and its length n, can identify a palindrome

using only one scan from left to right (which means you can only access each letter once). Your

algorithm must employ the use of either a queue or a stack, and you must justify your choice.

If you use a stack myou must use PUSH() and POP(), and if you use a queue you must use ENQUEUE()

and DEQUEUE().

Assume for simplicity every input will be of even length.

Page 3 of 5

COMP20007 Design of Algorithms, Semester 1, Mid-Semester Practice Test, 2022

Question 3 [3 Marks]

The following graph represents a road network where each edge presents a road segment. The costs of

the road segments are given in the figure below. There are three hospitals at nodes B, D, and E, and an

accident occurs at node H.

(a) Which algorithm would you use to find the nearest hospital from the accident. Explain how and

why you would use this algorithm.

(b) Which is the nearest hospital, which path would you take and what is the cost of this path? You

must show the execution of the algorithm described above.

(c) List the order of the nodes visited from H in the graph when a breadth-first search is used.

You should break ties in alphabetic order.

Page 4 of 5

COMP20007 Design of Algorithms, Semester 1, Mid-Semester Practice Test, 2022

Question 4 [3 marks]

Consider the following recursive function, which takes an unordered array of integers, A, and an integer,

k, and returns TRUE if k appears in A and FALSE otherwise.

function THIRDSSEARCH(A[0..n-1], k)

if n == 0 then

return FALSE

else if n == 1 then

return (A[0] == k)

else

a ← THIRDSSEARCH(A[0..n/3−1], k)

b ← THIRDSSEARCH(A[n/3..n×2/3−1], k)

c ← THIRDSSEARCH(A[n×2/3..n−1], k)

return (a OR b OR c)

For simplicity, you may assume the input array is of length n = 3

m for some positive integer m, so that

each recursive call gets an exact third of the input array.

(a) Write down, and solve, a recursive formula W(n) = ... which describes the number of steps taken

by THIRDSSEARCH on an array of length n, for the worst case input. Make sure you include the

base case(s). Keep in mind that the basic operation is usually the most frequent or most expensive

operation. Remember the formula for the geometric series states that.

(b) Use the language of Ω,O,Θ to bound the time complexity of THIRDSSEARCH, using T(n) for its

runtime. You must include an upper and lower bound. Full marks are awarded only to the tightest

possible bounds.

(c) Explain how THIRDSSEARCH could be slightly modified to improve its efficiency in the best case,

and repeat the analysis from part (b), with justification.

END OF TEST

联系我们

- QQ：99515681
- 邮箱：99515681@qq.com
- 工作时间：8:00-21:00
- 微信：codinghelp

- Fit5217辅导、Python程序语言辅导 2022-05-31
- 辅导ecs 170 Introduction To Artificial... 2022-05-31
- 辅导ecs 170 Homework Assignment 5 2022-05-31
- Fit 5003 Software Security辅导 2022-05-30
- 辅导cse 101 Data Structures And Algori... 2022-05-30
- 辅导econ7150、辅导java，Python编程 2022-05-30
- Econ7150编程辅导 讲解 S1 2022 2022-05-29
- 讲解cse 101 程序 辅导 Data Structures 2022-05-29
- 辅导fit 5003 Software Security 2022-05-29
- Stat7055 Introductory Statistics For B... 2022-05-28
- Assignment 3 Description: Computer Sy... 2022-05-28
- 辅导laboratory 程序、辅导program编程 2022-05-28
- 讲解eece 1080C Programming For Ece 2022-05-28
- Comp10002 Foundations Of Algorithms辅导... 2022-05-28
- 辅导 Swen30006、辅导java/C++编程 2022-05-28
- Comp326讲解导、辅导python，Java程序 2022-05-28
- 辅导 Dungeon Crawler C++ - Assignment ... 2022-05-27
- 辅导mast30025 Linear Statistical Model... 2022-05-27
- Prog2002辅导、辅导sql语言编程 2022-05-26
- 辅导 Info411/911 Data Mining Knowledge... 2022-05-26