0% found this document useful (0 votes)
10 views4 pages

TOC_2_Mark_Answers

Uploaded by

rameshdivya868
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)
10 views4 pages

TOC_2_Mark_Answers

Uploaded by

rameshdivya868
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/ 4

Theory of Computation - 2-Mark Answers

1. Transition diagram to recognize a constant:

A constant (e.g., integer) can be recognized by a finite automaton with states for digits 0-9. For a

decimal constant:

q0 --digit--> q1

q1 --digit--> q1

Start at q0, on digit go to q1 and stay on q1 for more digits.

2. Define Deterministic Finite Automata (DFA):

A DFA is a 5-tuple (Q, Sigma, delta, q0, F) where:

Q = finite set of states, Sigma = input alphabet, delta = transition function,

q0 = initial state, F = set of final states.

3. Regular expression for L = {strings with even 1s followed by odd 0s}:

((0*10*1)*)0(00)*

(Even 1s part + odd number of 0s part)

4. Pumping Lemma for Regular Languages:

For any regular language L, there exists a constant p such that any string s in L with |s| >= p can be

split into xyz satisfying:

1. |y| > 0, 2) |xy| p, 3) for alli >= 0, xyz in L.

5. Define Ambiguous Grammar (with Example):

A grammar is ambiguous if a string in the language has more than one parse tree.

Example:

S -> S + S | S * S | a

a + a * a has two parse trees.

6. Leftmost derivation for aaabbabbba:

Using grammar:
S -> aB

B -> aBB -> aB -> bS -> bA -> bAA -> bAa -> baaa

Full derivation (step-by-step) is lengthy but follows replacing leftmost non-terminal.

7. Define CNF and GNF:

CNF (Chomsky Normal Form): Rules are of form A -> BC or A -> a.

GNF (Greibach Normal Form): Rules are of form A -> aalpha where a is terminal, alpha is (possibly

empty) string of non-terminals.

8. Three ways to simplify a CFG:

1. Remove useless symbols

2. Eliminate null productions

3. Remove unit productions

9. What is recursively enumerable language?

A language is recursively enumerable (RE) if there exists a Turing Machine that accepts all strings in

the language (but may not halt for non-members).

10. What is a Universal Turing Machine?

A Universal Turing Machine can simulate any Turing Machine. It takes as input the description of a

Turing Machine and a string and simulates it.

11. (Duplicate) Define Deterministic Finite Automata:

Already answered in Q2 above.

12. Applications of Automata Theory:

1. Compiler design

2. Text pattern matching (e.g., grep, regex)

3. Network protocol verification

13. FA for unary number divisible by 3:

States: q0 (start/accept), q1, q2

Transitions:
q0 --1--> q1

q1 --1--> q2

q2 --1--> q0

Accept at q0.

14. Difference between Regular Expression and Regular Language:

Regular Expression is a symbolic way to represent a language.

Regular Language is the set of strings accepted by a finite automaton or described by a regex.

15. (Duplicate) Pumping Lemma for Regular Language:

Already answered in Q4 above.

16. Show whether L = {0^n12^n | n > 0} is regular using Pumping Lemma:

Assume it is regular. Let s = 0^p1 2^p. Pump and break 0s, resulting in unequal number of 0s and

2s. Violates pattern -> Not regular.

17. What is CFL (Context-Free Language)?

A CFL is a language generated by a context-free grammar (CFG), where each production is of the

form A -> alpha (A is non-terminal, alpha is string).

18. When is a grammar ambiguous?

A grammar is ambiguous if at least one string has more than one leftmost derivation or parse tree.

19. Properties of Recursive & Recursively Enumerable Languages:

Recursive: Decidable, TM always halts

RE: Semi-decidable, TM may not halt for non-members

Recursive subset RE

20. Closure Properties of CFGs:

CFGs are closed under:

1. Union

2. Concatenation

3. Kleene star
Not closed under: Intersection, Complement

You might also like