CAC Question Bank 24
CAC Question Bank 24
2. Explain the difference between context-free grammars and regular grammars 4 CO1 2
in the context of programming languages.
4. Describe the different classes of grammars based on the Chomsky hierarchy 7 CO1 3
and their relevance in programming language theory.
8 Explain the difference between lexical analysis and syntax analysis. 4 CO1 3
9 Explain the concept of top-down parsing and its importance in language 4 CO1 3
processing.
11 Describe the process of bottom-up parsing and its applications in language 4 CO1 3
processing.
12 What are language processor development tools, and why are they important 4 CO1 3
in software development?
13 Compare and contrast lexical analysis tools such as LEX with parser generators 4 CO1 3
like YACC
5 What are the causes of the large semantic gap between high-level 4 CO2 3
programming languages and machine languages? How does it affect compiler
design?
6 Define binding and binding times in the context of compiling. Provide 4 CO2 2
examples of each.
7 Describe the data structures commonly used in compiling processes and their 4 CO2 2
role in efficient code generation.
8 Explain scope rules in programming languages and how they influence 4 CO2 3
compilation.
10 Outline the compilation process for expressions and control structures. 4 CO2 2
11 What is code optimization in compiling? Discuss various techniques used for 4 CO2 2
code optimization.
13 Explain the procedures involved in debugging programs using interpreters and 4 CO2 2
debuggers.
15 Define macro definition and call in the context of macro processors. 4 CO2 2
16 Explain the process of macro expansion and its significance in code generation. 4 CO2 2
17 Discuss nested macro calls and their handling in macro processing. 4 CO2 2
19 Identify and discuss the design issues commonly encountered in macro 4 CO2 3
processors.
20 Introduce the concepts of linkers and loaders in the context of software 4 CO2 3
development.
21 Describe the design of a linker and its role in generating executable code. 7 CO2 3
24 Compare and contrast the functionalities of linkers and loaders, highlighting 7 CO2 3
their respective roles in the compilation and execution process.
1 Using Principle of Mathematical Induction, prove that for every n >= 1, 4 CO3 4
N Σ i = n (n+1) / 2 i=0
2 Using Principle of Mathematical Induction, prove that for every n >= 1, 4 CO3 4
7 + 13 + 19 + . . . + (6n + 1) = n(3n +4)
5 Using Principle of Mathematical Induction, Prove that For every n >= 1, 4 CO3 4
N Σ i2 = n (n+1)(2n+1)/ 6 i=1
8 Define relation. Define reflexive and transitive relation. A binary relation R on 7 CO3 4
NxN is defined as (a,b)R(c,d) if a ≤ c or b ≤ d. Prove that R is reflexive but not
transitive.
11 Define Mathematical Induction principle and prove that for any n>=4, n!>2n 4 CO3 4
14 Let A = {1, 2, 3, 4, 5, 6} and R be a relation on A such that aRb iff a is a multiple 7 CO3 4
of b.
Write R. Check if the relation is i) Reflexive ii) Symmetric iii) Asymmetric iv)
Transitive
17 Write theorem: For any NFA M =(Q,Σ,q0,A,δ) accepting a language L, there is an 7 CO3 4
FA M1 =(Q,Σ,q1,A1,δ1) that also accepts L.
18 Write Kleene’s Theorem part-I, Any regular language can be accepted by a 7 CO3 4
finite automation.
21 Write Regular Expressions for the following languages of all strings in {0,1}* 4 CO3 5
(i) Strings that do not end with 01.
(ii) Strings with odd numbers of 1’s (Ones).
22 Define Nondeterministic Finite Automata (NFA) and write down recursive 7 CO3 4
definition of δ* for NFA- Λ.
23 Write definition of Finite Automata and draw FA for the strings: 4 CO3 3
(i) The string with next to last symbol as 0.
(ii) The string with number of 0s odd and number of 1s odd.
A {B} {A} Ǿ
B {D} {C} Ǿ
C Ǿ Ǿ {B}
D Ǿ {D} Ǿ
25 For the following Regular Expression draw an NFA- Λ recognizing the 7 CO3 4
corresponding languages.
(i) (00 + 1)* (10)*
(ii) 001*0*11
30 Define δ* for! FA- NFA and NFA-Λ. Also Calculate δ* (1, ab) and δ* (1, abaab) 7 CO3 4
from the following transition table.
Q δ(q,a) δ ( q , b)
1 { 1 , 2} {1}
2 { 3} {3}
3 {4} {4}
4 {5} Ø
5 Ø {5}
34 Enlist applications where the finite automaton is useful. Also Find a string of 7 CO3 4
minimum length in {0,1}* not in the language corresponding to the regular
expression : 1*(0+10)*1*
35 Explain the procedure for converting the given DFA in to minimum number of 7 CO3 4
state DFA. Using this procedure convert the following DFA into minimum
number of states DFA (minimized FA) where Σ = {0,1}.
Q δ(q,a) δ(q,b)
- +1 {3} {2}
2 {4} {1}
3 {5} {4}
4 {4} {4}
5 {3} {2}
37 Write Regular Expressions for the following languages of all strings in {0,1}* 4 CO3 4
(i) Strings that contains odd number of 0’s (zeroes).
(ii) Strings that begin or end with 00 or 11.
38 Write definition of finite automata and draw FA for the strings: 7 CO3 4
(i)The string in {0,1}* ending in 10 or 11.
(ii)The string corresponding to Regular expression {11}*{00}*
A {B,D} {A} Ǿ
B Ǿ {C} {E}
C Ǿ Ǿ {B}
D Ǿ {E} {D}
E Ǿ Ǿ Ǿ
40 Compare FA, NFA and NFA- Λ. For the following Regular Expression draw an 7 CO3 4
NFA-Λ recognizing the corresponding language. (0 + 1)* (10+01)* 11
42 Write Regular Expressions for the following languages of all strings in 7 CO3 5
{0,1}*
(i) Strings that start with 1 and do not end with 10.
(ii) Strings with length 6 or less.
43 For the following Regular Expression draw an NFA- Λ recognizing the 7 CO3 4
corresponding language.
(0 + 1)* (10+110)* 1
50 For each of the following regular expressions, draw an FA recognizing the 7 CO3 4
corresponding language.
i. 1(01 + 10)* + 0(11 + 10)*
ii. (010 + 00)*(10)*
51 Let M1, M2 and M3 be the FAs pictured in Figure below, recognizing languages 7 CO3 4
L1, L2, and L3 respectively.
53 Define NFA and NFA-Λ. Convert the following NFA to DFA 7 CO3 4
54 Minimize the following FSM 7 CO3 4
60 Convert the NFA given in Table below to its corresponding DFA and draw the 7 CO3 4
DFA.
61 Write a regular expression for language L over {0,1} such that every string in L 4 CO3 4
i) Begins with 00 and ends with 11.
ii) Contains alternate 0 and 1.
62 Give recursive definitions of the extended transition functions, δ̂ ̂(i.e., for 7 CO3 4
strings) for DFA and NFA.
65 Using constructive approach determine NFA- Λ for the regular expression (0 + 7 CO3 5
1)*1(0 + 1).
69 Draw NFA – Λ for ((0 + 1)*10 + (00)*(11)*)* Show step by step construction. 7 CO3 4
70 An NFA with states 1-5 and input alphabet {a, b} has the following transition 7 CO3 4
table.
74 Write Regular Expression over the alphabets {a, b} consisting strings: 4 CO3 4
● Second last character as ‘a’
Starting with ‘a’ and ending with ‘b’
75 Construct fin finite automata for following left linear grammar: 7 CO3 4
S → X0 | Y1
X → Y1
Y → Y0 | 1
76 Convert the following NFA - Ʌ into its equivalent DFA that accepts the same 7 CO3 4
language:
77 Find a minimum-state FA for the following FA that recognizes the same 7 CO3 4
language using the minimization algorithm:
1 Write theorem: If L1 and L2 are context free languages, then the language L1 U 4 CO4 3
L2, L1⋂L2 and L1* are also CFLs.
6 Prove: There are context-free languages L1 and L2 so that L1 ∩ L2 is not a CFL 4 CO4 3
and there is a CFL L so that L’ is not a CFL
7 Given the CFG G, find a CFG G’ in Chomsky Normal form generating L(G) – { Λ} 7 CO4 4
S→ AaA | CA | BaB
A→ aaBa | CDA | aa | DC
B→ bB | bAB | bb | aS
C→ Ca | bC | D
D→ bD | Λ
8 Explain Derivation Tree, Expression Tree and Ambiguity with Example. 4 CO4 3
9 For the following CFG’s, describe the language it accepts. 4 CO4 4
1. S → SS | XaXaX | ^
X → bX | ^
2. S→aM | bS
M→aF | bS
F→aF | bF | ^
3. S→aS | bS | a | b | ^
11 Given the context-free grammar G, find a CFG G’ in Chomsky Normal Form 4 CO4 4
generating L(G) – {^}. G has production S→S(S) | ^
12 Define Context Free Grammar (CFG). Describe the language accepted by 4 CO4 4
following CFG:
S→aSa | bSb | a | b | Λ
14 Convert the following CFG to the equivalent Chomsky Normal Form(CNF). 7 CO4 4
S→AACD | ACD | AAC | CD | AC | C
A→aAb | ab
C→aC | a
D→aDa | bDb | aa | bb
17 Let L be the language corresponding to the regular expression (011+1)* (01)*. 4 CO4 3
Find the CFG generating L.
18 Given the CFG G, find a CFG G’ in Chomsky Normal form generating L(G) – { Λ} 7 CO4 4
S→A | B | C
A→aAa | B
B→bB | bb
C→aCaa | D
D→baD | abD | aa
19 Define CFG and Design a CFG for the following language. 4 CO4 4
L = { x ∈ {0,1}* | n0(x) ≠ n1(x) }
22 Define Context Free Grammar (CFG). Design CFG for Generating Following 4 CO4 4
Language:
(1) For Balanced Parenthesis
(2) Set of even length strings in {a, b, c, d}* with two middle symbol equal.
23 Design an ambiguous grammar for if-then-else statement that also generates 4 CO4 5
if-then statement. Re-write an equivalent unambiguous grammar. Prove that
Grammar is Unambiguous by tracing “ic1tic2taea”.
1 Find CFG from given PDA that accepts the language {0n1n}. PDA is (Q, Σ, Г, δ, q, 7 CO4 4
Z, F) where Q={q, r}, Σ = {0, 1}, Г = {Z, X}, δ is defined by:
2 (1) Given the Context Free Grammar G, find a CFG G’ in Chomsky Normal 4 CO4 4
Form generating L(G) – { }
S → SS | A | B
A → SS | AS | a
B → /\
(2) Convert following CFG to PDA
S → 0S1 | 00 | 11
3 Given the Context Free Grammar G, find a CFG G’ in Chomsky Normal Form 7 CO4 4
generating L(G) – { }
1) S → aY | Ybb | Y
X → /\ | a
Y → aXY | bb | XXa
2) S → AA
A → B | BB
B → abB | b | bb
4 Define Context Free Grammar. Design a CFG for the following language. 4 CO4 4
L = { x ε (0,1)* | n0(x) = n1(x)}
8 Given the Context Free Grammar G, find a CFG G’ in Chomsky Normal Form 7 CO4 4
generating L(G) – { }
S → aY | Ybb | Y
X → /\ | a
Y → aXY | bb | XXa
11 Prove that the following language is ambiguous and convert into unambiguous 4 CO4 4
E → E + E | E * E | id
13 (i) Write a CFG for solving simple (& parenthesized) expression, such as + and 7 CO4 4
*.
(ii) Also write CFG fir regular expression r = (a + b) (a + b + 0 + 1)* Use CFG
defined for part (i).
(iii) Derive the string (which is defined in part (ii)) a * (a + b00) by applying
left most derivation and right most derivation.
14 Define Context Free Grammar. Design a CFG for the language 4 CO4 4
L = { aibjck | i ≠ j + k }
15 Define Context Free Grammar. Find context-free grammar for the language: L = 4 CO4 4
{aibj | i < 2j}
16 Explain Union Rule and Concatenation Rule for Context-Free Grammar. 4 CO4 4
17 Decide whether the given language is a CFL, and prove your answer. 4 CO4 4
L = { xyx | x, y ϵ {a, b}* and |x| ≥ 1}
23 Eliminate useless symbols, ε -productions and unit productions for the 4 CO4 4
following grammar:
S→0A0 | 1B1 | BB, A→C, B→S | A, C→S | ε
25 Prove that – “If there is a CFG for the language L that has no Ʌ-productions, 4 CO4 4
then there is a CFG for L with no Ʌ-productions and no unit productions”.
Support your answer with the help of the following CFG: S →A | bb A →B | b B
→S | a
27 Write transition table for PDA recognizing following language: { aibjck | j = i or j 7 CO5 4
= k }.
28 For the language L = { xcxr / x Є {a,b}* } design a PDA(Push Down Automata) 7 CO5 4
and trace it for string “abcba”.
29 Design and draw a deterministic PDA accepting “Balanced strings of Brackets” 7 CO5 4
which are accepted by following CFG.
S→ SS | [ S ] | { S } | Λ
30 Define PDA and design PDA for L = { x ∈ { a, b}* | na(x) > nb(x) } 7 CO5 5
31 Give transition table for deterministic PDA recognizing the following language. 7 CO5 4
{ an bn+m am | n,m ≥ 0)
32 Give transition table for deterministic PDA recognizing the following language. 7 CO5 4
{ aibjck | i, j, k ≥ 0 and j = i or j = k }
33 Design and draw a deterministic PDA accepting strings with more a’s than b’s. 7 CO5 5
Trace it for the string “abbabaa”.
34 Prove: The language pal= { x ∈ {a, b}* | x = xr } cannot be accepted by any 7 CO5 4
deterministic pushdown automaton.
36 For the language L={set of strings over alphabet {a, b} with exactly twice as 7 CO5 4
many a’s as b’s} design a PDA (Push Down Automata) and trace it for the string
“abaabbaaaaabaab”
37 For the language L={ aibjck | i, j, k ≥ 0 and i + j = k } design a PDA (Push Down 7 CO5 4
Automata) and trace it for String “bbbbbccccc”
39 Consider following PDA machine M = ({p, q}, {0,1}, (x, z}, δ, q, Z) where δ is 7 CO5 5
given by
δ(q, 1, z) = (q, xz)
δ(q, 1, x) = (q, xx)
δ(q, ^, x) = (q,^)
δ(q, 0, x) = (p, x)
δ(p, 1, x) = (p, ɛ)
δ(p, 0, z) = (q, z)
Construct Equivalent CFG.
40 For the PDA, ( {q0, q1}, {0, 1}, {0, 1, z0}, δ, q0, z0, ϕ ), 7 CO5 5
where δ is
δ(q0, ɛ, z0) = {(q1, ɛ)}
δ(q0, 0, z0) = {(q0, 0z0)}
δ(q0, 0, 0) = {(q0, 00)}
δ(q0, 1, 0) = {(q0, 10)}
δ(q0, 1, 1) = {(q0, 11)}
δ(q0, 0, 1) = {(q1, ɛ)}
δ(q1, 0, 1) = {(q1, ɛ)}
δ(q1, 0, 0) = {(q1, ɛ)}
δ(q1, ɛ, z0) = {(q1, ɛ)}
Obtain CFG accepted by the above PDA.
41 Define PDA and give PDA to accept strings of palindrome. Show trace on the 7 CO5 4
string baab
44 Show using the pumping lemma that the following language is not a CFL. 7 CO5 4
L={aibjck | i <j <k}
46 Prove that the context-free languages are closed under union. 7 CO5 4
3 Define Turing Machine. Describe its capabilities. Also write short notes on 7 CO5 4
Universal Turing Machine.
4 Draw a Turing Machine(TM) to accept Palindromes over {a,b}. (Even as well as 7 CO5 4
Odd Palindromes)
7 Draw a transition diagram for a Turing machine accepting the following 7 CO5 4
language. { an bn cn | n ≥ 0 }
8 Draw a transition diagram for a Turing machine accepting the following 7 CO5 4
language.
{ x є { a, b, c }* | na(x) = nb(x) = nc(x) }
10 Draw Turing Machine(TM) which recognizes words of the form { anbncn | n≥ 1 } 7 CO5 4
11 Design a Turing machine for deleting nth symbol from a string w from the 7 CO5 4
alphabet Σ = {0, 1}.
15 Design a Turing machine to reverse the string over alphabet {0, 1} 7 CO5 3
16 Compare and contrast push down automata and Turing machine. 4 CO5 3
18 Design a Turing machine which accepts the language consisting string which 7 CO5 3
contain aba as a substring over alphabets {a, b}
19 Draw a Turing Machine that accepts the language {anbnan | n ≥0} over {a,b}∗. 7 CO5 4
Also trace the TM on input string aaabbbaaa.
20 Draw a Turing Machine that accepts the language {xx | x ∈{a,b}∗}. Also trace 7 CO5 4
the TM on input string aa.