DUBLIN CITY UNIVERSITY SEMESTER ONE EXAMINATIONS 2004

advertisement
DUBLIN CITY UNIVERSITY
SEMESTER ONE EXAMINATIONS 2004
MODULE:
(Title & Code)
CA215
Languages and Computability
COURSE:
B.Sc. in Applied Computational Linguistics
B.Sc. in Computer Applications (IS Stream)
B.Sc. in Computer Applications (SE Stream)
B.Sc. in Computer Applications (Evening)
YEAR:
2
EXAMINERS:
Dr. G.W. Hamilton
Mr. Dudley Dolan
Dr. Donncha O’Maidin
(Including telephone Nos.)
Ext: 5017
TIME ALLOWED: 2 Hours
INSTRUCTIONS:
Please answer all 10 questions: All questions carry equal
marks
Requirements for this paper
Please tick (X) as appropriate
Log Table
Graph Paper
Attached Answer Sheet
Statistical Tables
Floppy Disk
Actuarial Tables
THE USE OF PROGRAMMABLE OR TEXT STORING
CALCULATORS IS EXPRESSLY FORBIDDEN
PLEASE DO NOT TURN OVER THIS PAGE UNTIL YOU ARE
INSTRUCTED TO DO SO
Question 1
CA215 Languages and Computability
Page 1 of 4
Show whether or not the set of all even integers {…,-4,-2,0,2,4,…}
is countable.
[10 marks]
Question 2
Write a regular expression which describes the language of binary
numbers from the alphabet {0,1} which are either odd or a power
of 2 (or both).
[10 marks]
Question 3
Construct a deterministic finite-state automaton to recognise the
language described in Question 2.
[10 marks]
Question 4
Consider the following grammar with start symbol S:
[10 marks]
S  if id then S else S
S  if id then S
S  id
Show that this grammar is ambiguous by giving two distinct parse
trees for the following sentence:
if id then if id then id else id
Question 5
Consider the following grammar with start symbol E:
[10 marks]
E  E+T | E-T | T
T  T*F | T/F | F
F  (E) | id
Give a derivation of the following sentence:
id*(id-id)/id
Question 6
Construct a pushdown automaton that recognises the language
[10 marks]
{ajbk: j  k}
Question 7
CA215 Languages and Computability
Page 2 of 4
Consider a Turing machine with start state 0 and the following
transitions:
State Symbol
[10 marks]
(State, Symbol)
0
a
(1, #, R)
0
b
(4, #, R)
0
#
(0, #, Y)
1
a
(1, a, R)
1
b
(1, b, R)
1
#
(2, #, L)
2
a
(3, #, L)
2
#
(2, #, Y)
3
a
(3, a, L)
3
b
(3, b, L)
3
#
(0, #, R)
4
a
(4, a, R)
4
b
(4, b, R)
4
#
(5, #, L)
5
b
(3, #, L)
5
#
(5, #, Y)
Trace the execution of this Turing machine with the string
baaab#
as input.
Question 8
Describe the language which is accepted by the Turing machine in
Question 7.
[10 marks]
What is meant by the statement f(n) = O(g(n))?
What is the time complexity of the Turing machine in Question 7
(in terms of O(f(n)) notation) for an input of length n?
Question 9
CA215 Languages and Computability
Page 3 of 4
Is the following problem decidable? Give a proof of your answer.
[10 marks]
Given a Turing machine T and a string w, does T loop forever on
input w?
Question 10
Describe what is meant by each of the following:
(a)
(b)
(c)
[10 marks]
Recursive languages
Recursively enumerable languages
Primitive recursive functions
Show that the function to add together two natural numbers is
primitive recursive.
CA215 Languages and Computability
Page 4 of 4
Download