0% found this document useful (0 votes)
2 views

Level_2_Theory_of_Computation_COMP2181WE01_1

The document is an examination paper for the Theory of Computation course (COMP2181-WE01) for the May/June 2021 session. It includes instructions for a take-home exam, detailing the format, submission method, and various questions across sections on Models of Computation, Algorithms and Complexity I, and II. Each section contains multiple questions requiring theoretical and practical responses related to computation models, algorithms, and complexity theory.

Uploaded by

Veer Patel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Level_2_Theory_of_Computation_COMP2181WE01_1

The document is an examination paper for the Theory of Computation course (COMP2181-WE01) for the May/June 2021 session. It includes instructions for a take-home exam, detailing the format, submission method, and various questions across sections on Models of Computation, Algorithms and Complexity I, and II. Each section contains multiple questions requiring theoretical and practical responses related to computation models, algorithms, and complexity theory.

Uploaded by

Veer Patel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Examination Paper

Examination Session: Year: Exam Code:

May/June 2021 COMP2181-WE01

Title: Theory of Computation

Release Date/Time 9.30am 13/05/2021

Deadline Date/Time 9.30am 14/05/2021

Format of Exam Take home exam

Duration: 2 hours

Word/Page Limit: None

Additional Material None


provided:

Expected form of A SINGLE PDF file (handwritten or typed) submitted onto Gradescope.
Submission
Upload your submission with a file name comprising of your student ID
and the Exam Code e.g 00001234532 COMP2181-WE01.
Submission method Gradescope

Instructions to Candidates: Answer ALL questions.


Page 1 of 5 COMP2181-WE01

Section A Models of Computation


(Dr Stefan Dantchev)

Question 1

(a) Construct a Turing Machine that accepts well-formed arithmetic expres-


sions over variables a, b and c with addition, +, multiplication, ×, and
brackets, ( and ).
There is no need to give the precise transition function - you could explain
how the machine works in plain English. You may use multiple tapes in
your machine. [10 Marks]

(b) Describe a procedure that, for a given Turing Machine A, produces a


(potentially infinite) list of all words that are accepted by A, and nothing
else. [4 Marks]

(c) Suppose that you are given a Turing Machine A, whose language L (A) is
infinite. Describe a Turing Machine B that always terminates and decides
an infinite language L (B) which is a subset of L (A). [6 Marks]

(d) For a fixed tape language, e.g. {0, 1, t}, let f (n) be the maximum number
of steps that any Turing Machine with n states makes before it terminates
when ran on the empty input. Prove that the function f (n) is not com-
putable. [5 Marks]

continued
Page 2 of 5 COMP2181-WE01

Question 2

(a) Design a deterministic Büchi Automaton that recognises the language that
contains the infinite binary words that start with a 1 and have non-empty
finite segments of 0s of even length separated by single 1s. [7 Marks]

(b) For an infinite binary word, consider the sequence of the lengths of its
alternating segments of 0s and 1s. For instance, the sequence for the word
0011101010001 . . . would be 2, 3, 1, 1, 1, 1, 3, . . . . Prove that the language
consisting of all words for which this sequence is strictly increasing is not
recognisable by any Büchi Automaton. [10 Marks]

(c) Evaluate the Computation Tree Logic (CTL) formula A(q U EXp) on all
states of the model below and show all your work. [8 Marks]

r, p p

p p, q q, r

q, r q

p, q, r

End of Section A continued


Page 3 of 5 COMP2181-WE01

Section B Algorithms and Complexity I


(Dr George Mertzios)

Question 3

(a) Suppose that you have a collection of n identically-looking coins, where


exactly n − 1 of them are gold coins and exactly one of them is a fake
coin. Moreover, you know that the fake coin is lighter than any gold coin,
while every two gold coins have the same weight. Assuming that you
have a balance scale, describe an efficient divide-and-conquer algorithm
which detects the fake coin using the smallest possible number of scaling
iterations. How many scaling iterations does your algorithm asymptotically
need in worst case? Justify your answer using the appropriate recurrence
relation. [7 Marks]

(b) An example of a greedy coloring algorithm is First-Fit. Given an input


graph G, this algorithm considers an arbitrary ordering u1 , . . . , un of its
vertices. For every i = 1, . . . , n, First-Fit assigns vertex ui the smallest
color from {1, 2, . . .} that does not already appear as a color of some vertex
which is adjacent to ui .

i. What is the running time of First-Fit on graphs on n vertices?


Justify your answer. [2 Marks]
ii. Using a counterexample of at most 6 vertices, show that First-Fit
does not compute the optimum number of colors needed to color
graph G. [5 Marks]

(c) i. Recall that two n × n matrices can be multiplied using Strassen’s


algorithm in O(nlog2 7 ) time. How quickly can you multiply a kn × n
matrix A with a n × kn matrix B, using Strassen’s algorithm as a
subroutine? Justify your answer. [3 Marks]
ii. The matrix squaring problem takes as input an n × n matrix A and
returns A2 . Show that matrix squaring is equally hard with matrix
multiplication. That is, show that, if we have an algorithm ALG for
one of the problems, we can use ALG to also solve the other problem
with the same asymptotic complexity.
Hint: given two n × n matrices A and B, define an auxiliary 2n × 2n
matrix. [8 Marks]

End of Section B continued


Page 4 of 5 COMP2181-WE01

Section C Algorithms and Complexity II


(Dr George Mertzios)

Question 4

(a) The output of Dijkstra’s algorithm is two arrays d and π, where d records
the distance from the source vertex to the other vertices and π records
predecessors. Compute d and π when Dijkstra’s algorithm is performed on
the weighted directed graph G represented by the adjacency matrix below,
where the source vertex corresponds to the first row and first column of
the matrix. [8 Marks]
 
0 6 4 5 2 0 0 0
 

 0 0 0 0 0 0 4 0 

 
 0 1 0 2 0 5 0 0 
 

 0 0 0 0 0 0 0 0 

 

 2 5 0 1 0 4 0 0 

0 0 1 0 0 0 2 0 
 

 

 0 0 0 0 0 0 0 8 

0 0 0 0 0 6 0 0

(b) Let G be a graph with n vertices and let k be a positive integer where
n
2
< k ≤ n. Let H be the graph obtained by adding 2k − n vertices (but
no further edges) to G. Show that H contains a clique of size k if and
only if G contains a clique of size k. [2 Marks]

(c) Let G be a graph with n vertices and let k be a positive integer where
k ≤ n2 . Let H be the graph obtained by adding n − 2k vertices to G and
adding edges from each of these new vertices to every other vertex (to
both old and new vertices). Show that H contains a clique of size n − k
if and only if G contains a clique of size k. [7 Marks]

continued
Page 5 of 5 COMP2181-WE01

(d) Consider the following two decision problems:

Clique
Instance: an undirected graph G = (V, E) and an integer k.
Question: does G have a clique containing at least k vertices?

Half Clique
Instance: an undirected graph G = (V, E).
Question: does G have a clique containing exactly half of its
vertices?

It is known that Clique is NP-hard. Using this fact, prove that Half
Clique is NP-hard. [8 Marks]

END OF PAPER

You might also like