Cosc 340
Cosc 340
COLLEGE
(A Constituent College of Chuka University)
UNIVERSITY EXAMINATIONS
INSTRUCTIONS:
SECTION A: COMPULSORY
QUESTION 1[30MKS]
Page 1 of 3
COSC 340
e) What is a derivation tree? Draw a derivation tree for the string "bab" from the CFG given by
S → bSb | a | b (4 marks)
f) Construct the CFG for the language having any number of a's over the set ∑= {a}. (4 marks)
a) What do you understand from the following terms as used in theory of computation? (6 marks)
(i) Regular expression
(ii) Context free grammar
(iii) Ambiguous grammar
b) Construct a TM machine for checking the palindrome of the string of even length. The string is
ababbabaΔ. (9 marks)
c) Using a diagram if necessary, explain the FIVE operations of Turing machine. (5 marks)
c) Explain the pumping lemma for regular and non-regular languages (5 marks)
b) Write the regular expression for the language starting and ending with a and having any having any
combination of b's in between. (5 marks)
c) Write the regular expression for the language starting with a but not having consecutive b's.
(5 marks)
Page 2 of 3
COSC 340
a) Briefly describe the following terms as used in theory of computation. (10 marks)
(i) P Problem
(ii) Non-deterministic Finite automata
(iii) Turing machine
(iv) Push Down Automata
(v) Deterministic Finite automata
b) Draw a state diagram to show how the machine responds to the following input
Page 3 of 3