Aspire's Library

A Place for Latest Exam wise Questions, Videos, Previous Year Papers,
Study Stuff for MCA Examinations

UGC NET Computer Science Previous Year Questions (PYQs)

UGC NET Computer Science Compiler Design PYQ


UGC NET Computer Science PYQ
Consider the following finite automata F1 that accepts a language L.


Let F2 be a finite automata which is obtained by reversal of F1. Then which of the following is correct?





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science June 2023 (Paper II) PYQ

Solution

In the given automata, transitions are present in both directions among the states. Therefore, reversing the automata does not change the accepted language.

So,

$L(F1) = L(F2)$

UGC NET Computer Science PYQ

The number of tokens in the following line:

for i in range(begin : end : step) :






Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science June 2024 (Paper II) PYQ

Solution

Tokens are the smallest meaningful units of a program.


Break the statement:


for | i | in | range | ( | begin | : | end | : | step | ) | :


Tokens:


for


i


in


range


(


begin


:


end


:


step


)


:


Total tokens = 12


UGC NET Computer Science PYQ
The compiler for high level language that runs on one machine and produces code for other machine is called-





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science June 2023 (Paper II) PYQ

Solution

A compiler that runs on one machine but generates code for another machine is called a cross compiler.

UGC NET Computer Science PYQ
The maximum yield length of the following CNF CFG is

S → AB

A → CD

B → e

C → a

D → b





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science June 2023 (Paper II) PYQ

Solution

In CNF, for a finite grammar, if there are n variables, then maximum yield length can be up to:

$2^{n-1}$

Here, the variables considered are:

A, B, C, D

So,

$n = 4$

Maximum yield length:

$2^{4-1} = 2^3 = 8$

UGC NET Computer Science PYQ

What is the safest order while simplifying Context Free Grammar?






Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Dec 2022 Shift II (Paper II) PYQ

Solution

While simplifying a CFG, the safest order is:

First remove $\epsilon$-productions.

Then remove unit productions.

Finally remove useless symbols and productions.

Reason:

After removing $\epsilon$-productions, new unit productions may be created.

After removing unit productions, some symbols may become useless.

So, useless symbols should be removed at the end.

Correct order is:

$\epsilon$-productions → Unit productions → Useless symbols and productions


UGC NET Computer Science PYQ
Simplified expression/s for following Boolean function

$F(A,B,C,D)=\sum(0,1,2,3,6,12,13,14,15)$

is/are

(A) $A'B' + AB + A'C'D'$

(B) $A'B' + AB + A'CD'$

(C) $A'B' + AB + BC'D'$

(D) $A'B' + AB + BCD'$

Choose the correct answer from the options given below:





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Nov 2020 (Paper II) PYQ

Solution

Given minterms are:

$0,1,2,3,6,12,13,14,15$

$A'B'$ covers minterms $0,1,2,3$

$AB$ covers minterms $12,13,14,15$

Remaining minterm is $6$

Option (B):

$A'CD'$ covers minterms $2,6$

Both are present in the function.

So, option (B) is correct.

Option (D):

$BCD'$ covers minterms $6,14$

Both are present in the function.

So, option (D) is also correct.

Options (A) and (C) include minterm $4$, which is not present in the function.

UGC NET Computer Science PYQ
An ambiguous grammar is one which has:

A. More than one derivations
B. More than one left most derivations
C. More than one right most derivations
D. More than one Parse tree
E. More than one syntax tree





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science June 2024 (Paper II) PYQ

Solution

A grammar is ambiguous if a string generated by it has more than one parse tree.


Equivalent definitions:


• More than one leftmost derivation

• More than one rightmost derivation


Thus the correct statements are:


B and C.


UGC NET Computer Science PYQ

A Turing Machine for the language
$L=a^n b^m c^n d^m \mid n \ge 1,\ m \ge 1$ is designed.

The resultant model is

$M=({q_0,q_1,q_2,q_3,q_4,q_5,q_6,q_7,q_f},{a,b,c,d},{a,b,c,d,X_1,X_2,Y_1,Y_2},\delta,q_0,B,{q_f})$

and part of $\delta$ is given in the transition table.

You need to write the following questions based on design of Turing Machine for the given language.

Note that, while designing the Turing Machine $X_1$ and $X_2$ are used to work with $a$'s and $c$'s and $Y_1$ and $Y_2$ are used to handle $b$'s and $d$'s of the given string.


What is the Move in the cell with number 'M1' of the resultant Table ?






Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Dec 2022 Shift II (Paper II) PYQ

Solution

$M1$ is used when the machine is in state $q1$ and reads symbol $c$.

In this stage, the machine has already marked one $a$ as $X1$ and is searching for the corresponding $c$.

So, when it finds $c$, it marks it as $X2$ and moves left to return back.

Therefore,

$M1=(q2,X2,L)$


UGC NET Computer Science PYQ

A Turing Machine for the language
$L=a^n b^m c^n d^m \mid n \ge 1,\ m \ge 1$ is designed.

The resultant model is

$M=({q_0,q_1,q_2,q_3,q_4,q_5,q_6,q_7,q_f},{a,b,c,d},{a,b,c,d,X_1,X_2,Y_1,Y_2},\delta,q_0,B,{q_f})$

and part of $\delta$ is given in the transition table.

You need to write the following questions based on design of Turing Machine for the given language.

Note that, while designing the Turing Machine $X_1$ and $X_2$ are used to work with $a$'s and $c$'s and $Y_1$ and $Y_2$ are used to handle $b$'s and $d$'s of the given string.


What is the Move in the cell with the number $M2$ of the resultant Table?






Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Dec 2022 Shift II (Paper II) PYQ

Solution

$M2$ is in state $q0$ on symbol $X1$.

In standard Turing Machine design for this language, $X1$ represents an already marked $a$.

So, the machine should skip $X1$ and move right to search for the next unmarked $a$.

Correct move should be:

$(q0,X1,R)$

But this option is not present in the given options.


UGC NET Computer Science PYQ

A Turing Machine for the language
$L=a^n b^m c^n d^m \mid n \ge 1,\ m \ge 1$ is designed.

The resultant model is

$M=({q_0,q_1,q_2,q_3,q_4,q_5,q_6,q_7,q_f},{a,b,c,d},{a,b,c,d,X_1,X_2,Y_1,Y_2},\delta,q_0,B,{q_f})$

and part of $\delta$ is given in the transition table.

You need to write the following questions based on design of Turing Machine for the given language.

Note that, while designing the Turing Machine $X_1$ and $X_2$ are used to work with $a$'s and $c$'s and $Y_1$ and $Y_2$ are used to handle $b$'s and $d$'s of the given string.


What is the Move in the cell with number $M3$ of the resultant Table?






Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Dec 2022 Shift II (Paper II) PYQ

Solution

$M3$ is in state $q3$ on symbol $a$.

State $q3$ is used after matching all $a$'s with $c$'s. Now the machine works on $b$'s and $d$'s.

So, if the machine sees an unmarked $a$ in state $q3$, it means the string is not in the correct form.

Hence, it is an error entry.


UGC NET Computer Science PYQ

A Turing Machine for the language
$L=a^n b^m c^n d^m \mid n \ge 1,\ m \ge 1$ is designed.

The resultant model is

$M=({q_0,q_1,q_2,q_3,q_4,q_5,q_6,q_7,q_f},{a,b,c,d},{a,b,c,d,X_1,X_2,Y_1,Y_2},\delta,q_0,B,{q_f})$

and part of $\delta$ is given in the transition table.

You need to write the following questions based on design of Turing Machine for the given language.

Note that, while designing the Turing Machine $X_1$ and $X_2$ are used to work with $a$'s and $c$'s and $Y_1$ and $Y_2$ are used to handle $b$'s and $d$'s of the given string.


What is the Move in the cell with number $M4$ of the resultant Table?






Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Dec 2022 Shift II (Paper II) PYQ

Solution

$M4$ is in state $q5$ on symbol $Y1$.

Here, $Y1$ represents a marked $b$.

After marking one corresponding $d$ as $Y2$, the machine moves left and reaches $Y1$.

Now it should move right and again go to state $q3$ to search for the next unmarked $b$.

Therefore,

$M4=(q3,Y1,R)$


UGC NET Computer Science PYQ
Let $G_1$ and $G_2$ be arbitrary context free languages and $R$ an arbitrary regular language. Consider the following problems:

$(A)$ Is $L(G_1)=L(G_2)$?

$(B)$ Is $L(G_2)\subseteq L(G_1)$?

$(C)$ Is $L(G_1)=R$?

Which of the problems are undecidable?





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Nov 2020 (Paper II) PYQ

Solution

For context free languages, equivalence problem is undecidable.

So,

$L(G_1)=L(G_2)$ is undecidable.

Also, inclusion problem for context free languages is undecidable.

So,

$L(G_2)\subseteq L(G_1)$ is undecidable.

Now,

$L(G_1)=R$

is also undecidable because if $R=\Sigma^*$, then this becomes CFL universality problem:

$L(G_1)=\Sigma^*$

which is undecidable.

Therefore, all three problems are undecidable.

UGC NET Computer Science PYQ
Shift-Reduce conflicts are resolved by :





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science June 2024 (Paper II) PYQ

Solution

In LR parsing, shift-reduce conflicts occur when the parser can either shift the next input symbol or reduce using a rule.


These conflicts are resolved using operator precedence and associativity rules.


UGC NET Computer Science PYQ

A Turing Machine for the language
$L=a^n b^m c^n d^m \mid n \ge 1,\ m \ge 1$ is designed.

The resultant model is

$M=({q_0,q_1,q_2,q_3,q_4,q_5,q_6,q_7,q_f},{a,b,c,d},{a,b,c,d,X_1,X_2,Y_1,Y_2},\delta,q_0,B,{q_f})$

and part of $\delta$ is given in the transition table.

You need to write the following questions based on design of Turing Machine for the given language.

Note that, while designing the Turing Machine $X_1$ and $X_2$ are used to work with $a$'s and $c$'s and $Y_1$ and $Y_2$ are used to handle $b$'s and $d$'s of the given string.


What is the Move in the cell with number $M5$ of the resultant Table?






Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Dec 2022 Shift II (Paper II) PYQ

Solution

$M5$ is in state $q4$ on symbol $X2$.

Here, $X2$ represents an already marked $c$.

In state $q4$, the machine is moving right to find an unmarked $d$ corresponding to a marked $b$.

So, when it sees $X2$, it simply skips it and moves right.

Therefore,

$M5=(q4,X2,R)$


UGC NET Computer Science PYQ
Consider the following languages:

$L_1=\{a^{2^z}\mid z\text{ is an integer}\}$

$L_2=\{a^{2z}\mid z\ge 0\}$

$L_3=\{\omega\omega\mid \omega\in\{a,b\}^*\}$

Which of the languages is or are regular?

Choose the correct answer from the options given below:





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Nov 2020 (Paper II) PYQ

Solution

For $L_1$:

$L_1=\{a^{2^z}\mid z\text{ is an integer}\}$

The possible lengths are:

$1,2,4,8,16,32,\ldots$

So,

$L_1=\{a,a^2,a^4,a^8,a^{16},\ldots\}$

This is not regular because the gap between consecutive string lengths keeps increasing.

So, $L_1$ is not regular.

For $L_2$:

$L_2=\{a^{2z}\mid z\ge 0\}$

The possible lengths are:

$0,2,4,6,8,\ldots$

So,

$L_2=\{\lambda,a^2,a^4,a^6,\ldots\}$

This language contains all strings of even length over alphabet $\{a\}$.

It can be written as:

$L_2=(aa)^*$

Since $(aa)^*$ is a regular expression, $L_2$ is regular.

For $L_3$:

$L_3=\{\omega\omega\mid \omega\in\{a,b\}^*\}$

In this language, the second half of the string must be exactly the same as the first half.

A finite automaton cannot remember the complete first half and compare it with the second half.

So, $L_3$ is not regular.

Therefore, only $L_2$ is regular.

UGC NET Computer Science PYQ
Which of the following grammars is or are ambiguous?

$(A)\ S\rightarrow SS\mid aSb\mid bSa\mid \lambda$

$(B)\ S\rightarrow aSbS\mid bSaS\mid \lambda$

$(C)\ S\rightarrow aAB$

$A\rightarrow bBb$

$B\rightarrow A\mid \lambda$

where $\lambda$ denotes empty string.

Choose the correct answer from the options given below:





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Nov 2020 (Paper II) PYQ

Solution

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

For grammar $(A)$:

$S\rightarrow SS\mid aSb\mid bSa\mid \lambda$

The string $abab$ can be generated in more than one way.

First derivation:

$S\Rightarrow SS$

$\Rightarrow aSbS$

$\Rightarrow abS$

$\Rightarrow abaSb$

$\Rightarrow abab$

Second derivation:

$S\Rightarrow aSb$

$\Rightarrow abSab$

$\Rightarrow abab$

So, grammar $(A)$ is ambiguous.

For grammar $(B)$:

$S\rightarrow aSbS\mid bSaS\mid \lambda$

The string $abab$ can be generated in more than one way.

First derivation:

$S\Rightarrow aSbS$

$\Rightarrow abS$

$\Rightarrow abaSbS$

$\Rightarrow abab$

Second derivation:

$S\Rightarrow aSbS$

$\Rightarrow a(bSaS)bS$

$\Rightarrow abab$

So, grammar $(B)$ is ambiguous.

For grammar $(C)$:

$S\rightarrow aAB$

$A\rightarrow bBb$

$B\rightarrow A\mid \lambda$

The string $abbbb$ can be generated in two ways.

First way:

$S\Rightarrow aAB$

$\Rightarrow a(bb)(bb)$

$\Rightarrow abbbb$

Second way:

$S\Rightarrow aAB$

$\Rightarrow a(bbbb)(\lambda)$

$\Rightarrow abbbb$

So, grammar $(C)$ is also ambiguous.

Therefore, grammars $(A)$, $(B)$ and $(C)$ all are ambiguous.

UGC NET Computer Science PYQ
Arrange the following parsers in increasing order of their power (least → most):
  1. LR(0)
  2. LR(1)
  3. LALR(1)
  4. LL(0)
  5. SLR
Choose the correct answer:





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science 26 June 2025 (Paper II) PYQ

Solution

  • LL(0) is the weakest (no lookahead, top-down).
  • LR(0) is stronger than LL(0) (bottom-up, no lookahead).
  • SLR(1) adds 1-symbol lookahead using FOLLOW sets → accepts more grammars than LR(0).
  • LALR(1) merges LR(1) states; more powerful than SLR(1) but below LR(1).
  • LR(1) is the most powerful among these deterministic bottom-up parsers.

UGC NET Computer Science PYQ
Consider following statements:

A. A context free language is generated by LR(0) grammar if and only if it is accepted by a deterministic pushdown automata and has prefix property.

B. If M1 is the single tape TM simulating multitape TM M, then time taken by M1 to simulate n moves is $(n^3)$.

C. Push down automata behaves like a Turing machine when it has one auxiliary memory.

D. $L={a^n b^n c^n : n \ge 1}$ is not context free but context sensitive.

Choose the correct answer from the options given below:





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science June 2023 (Paper II) PYQ

Solution

A is incorrect because LR(0) is a restricted class and the statement is not generally true.

B is incorrect because a single-tape TM can simulate a multitape TM with quadratic overhead, not cubic.

C is incorrect because a pushdown automata with one stack is not equivalent to a Turing machine.

D is correct because $L={a^n b^n c^n : n \ge 1}$ is not context free, but it is context sensitive.

UGC NET Computer Science PYQ
The reduced grammar equivalent to the grammar, whose production rules are given below, is

$S\to AB\mid CA$

$B\to BC\mid AB$

$A\to a$

$C\to aB\mid b$





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Sep 2022 (Paper II) PYQ

Solution

Given grammar:

$S\to AB\mid CA$

$B\to BC\mid AB$

$A\to a$

$C\to aB\mid b$

Here,

$A\to a$, so $A$ is generating.

$C\to b$, so $C$ is generating.

But $B\to BC\mid AB$ always contains $B$ again.

So, $B$ is non-generating.

Remove all productions containing $B$.

Remaining grammar is:

$S\to CA$

$A\to a$

$C\to b$

UGC NET Computer Science PYQ
Consider the production rules of grammer $G$:

$S\to AbB$

$A\to aAb\mid \lambda$

$B\to bB\mid \lambda$

Which of the following language $L$ is generated by grammer $G$?





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Sep 2022 (Paper II) PYQ

Solution

Given,

$S\to AbB$

$A\to aAb\mid \lambda$

So, $A$ generates equal number of $a$ and $b$.

$A\Rightarrow a^n b^n$

Also,

$B\to bB\mid \lambda$

So, $B$ generates any number of $b$.

$B\Rightarrow b^k$

Now,

$S\Rightarrow AbB$

$S\Rightarrow a^n b^n b b^k$

$S\Rightarrow a^n b^{n+k+1}$

So, number of $b$ is always greater than number of $a$.

Therefore,

$L=\{a^n b^m:n\ge 0,m>n\}$

UGC NET Computer Science PYQ
Consider the language

$L=\{a^n b^m:n\ge 4,m\le 3\}$

Which of the following regular expression represents language $L$?





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Sep 2022 (Paper II) PYQ

Solution

$n\ge 4$

So, at least $4$ symbols $a$ are compulsory.

This is represented by:

$aaaaa^*$

Also,

$m\le 3$

So, number of $b$ can be $0,1,2,$ or $3$.

This is represented by:

$\lambda+b+bb+bbb$

Therefore, required regular expression is:

$aaaaa^*(\lambda+b+bb+bbb)$

UGC NET Computer Science PYQ
Consider $L=\{ab,aa,baa\}$

Which of the following string is NOT in $L^*$?





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Sep 2022 (Paper II) PYQ

Solution

$L=\{ab,aa,baa\}$

Check option (b):

$abaabaaabaa=ab\cdot aa\cdot baa\cdot ab\cdot aa$

So, option (b) is in $L^*$.

Check option (c):

$aaaabaaaa=aa\cdot aa\cdot baa\cdot aa$

So, option (c) is in $L^*$.

Check option (d):

$baaaaabaa=baa\cdot aa\cdot ab\cdot aa$

So, option (d) is in $L^*$.

But option (a) cannot be completely divided into strings $ab,aa,baa$.

Therefore, $baaaaabaaaaa$ is NOT in $L^*$.

UGC NET Computer Science PYQ
Match List I with List II.$L_R$ : Regular language, $L_{CF}$ : Context free language$L_{REC}$ : Recursive language, $L_{RE}$ : Recursively enumerable language.
List I List II
(A) Recursively Enumerable language (I) $\overline{L_{REC}}\cup L_{RE}$
(B) Recursive language (II) $\overline{L_{CF}}\cup L_{REC}$
(C) Context Free language (III) $L_R^*\cap L_{CF}$
Choose the correct answer from the options given below:





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Nov 2020 (Paper II) PYQ

Solution

For (I),

$\overline{L_{REC}}\cup L_{RE}$

Recursive languages are closed under complement.

So, $\overline{L_{REC}}$ is also recursive.

Every recursive language is recursively enumerable.

Union of a recursively enumerable language with a recursive language is recursively enumerable.

So, (I) represents recursively enumerable language.

Therefore, (A) matches with I.

For (II),

$\overline{L_{CF}}\cup L_{REC}$

Every context free language is recursive.

Recursive languages are closed under complement.

So, $\overline{L_{CF}}$ is recursive.

Union of two recursive languages is recursive.

So, (II) represents recursive language.

Therefore, (B) matches with II.

For (III),

$L_R^*\cap L_{CF}$

Regular languages are closed under Kleene star.

So, $L_R^*$ is regular.

Intersection of a regular language with a context free language is context free.

So, (III) represents context free language.

Therefore, (C) matches with III.

Final matching is:

A-I, B-II, C-III

UGC NET Computer Science PYQ
Consider the following NPDA

$=({q_0,q_1,q_f},\{a,b\},\{1,z\},\delta,q_0,z,\{q_f\})$

$\delta(q_0,\lambda,z)=\{(q_f,z)\}$

$\delta(q_0,a,z)=\{(q_1,11z)\}$

$\delta(q_1,a,1)=\{(q_1,111)\}$

$\delta(q_1,b,1)=\{(q_1,\lambda)\}$

$\delta(q_1,\lambda,z)=\{(q_f,z)\}$

Which of the following Language $L$ is accepted by NPDA?





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Sep 2022 (Paper II) PYQ

Solution

For each input $a$, the NPDA pushes $2$ symbols $1$ into the stack.

For each input $b$, the NPDA pops $1$ symbol $1$ from the stack.

So, number of $b$ must be twice the number of $a$.

Therefore,

$L=\{a^n b^{2n}:n\ge 0\}$

Also, $\lambda$ is accepted because:

$\delta(q_0,\lambda,z)=\{(q_f,z)\}$

UGC NET Computer Science PYQ
The following code:

stmt → if expr then stmt else stmt
      | if expr then stmt

suffers from:





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science June 2024 (Paper II) PYQ

Solution

This grammar produces the dangling-else problem.

In such cases the else can be associated with more than one if, producing more than one parse tree.


Thus the grammar is ambiguous.


UGC NET Computer Science PYQ
Consider the following regular expressions:

(a) $r=a(b+a)^*$

(b) $s=a(a+b)^+$

(c) $t=aa^*b$

Choose the correct answer from the options given below based on the relation between the languages generated by the regular expressions above:





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Nov 2020 (Paper II) PYQ

Solution

For $r=a(b+a)^*$:

This represents all strings over $\{a,b\}$ that start with $a$.

So,

$L(r)=\{a,aa,ab,aaa,aab,aba,\ldots\}$

For $s=a(a+b)^+$:

Here, after first $a$, at least one more symbol from $\{a,b\}$ must be present.

So, $s$ represents all strings over $\{a,b\}$ that start with $a$ and have length at least $2$.

Therefore,

$L(s)\subseteq L(r)$

For $t=aa^*b$:

This represents strings of the form:

$ab,aab,aaab,aaaab,\ldots$

So, every string of $L(t)$ starts with $a$ and has length at least $2$.

Therefore,

$L(t)\subseteq L(s)$

Hence,

$L(r)\supseteq L(s)\supseteq L(t)$

UGC NET Computer Science PYQ
Consider the following statements:

A. The set of Turing machine codes for TM's that accept all inputs that are palindromes possible along with some other inputs is decidable

B. The language of codes for TM's M that when started with blank tape, eventually write a 1 somewhere on the tape is undecidable

C. The language accepted by a TM M is L(M) is always recursive

D. Post's correspondence problem is undecidable

Choose the correct answer from the options given below:





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science June 2023 (Paper II) PYQ

Solution

A is false because checking whether a TM accepts all palindromes is an undecidable property.

B is true because checking whether a TM writes 1 on a blank tape is undecidable.

C is false because the language accepted by a TM is recursively enumerable, but not always recursive.

D is true because Post's correspondence problem is undecidable.

UGC NET Computer Science PYQ
Given below are two statements:

Statement I: The problem "Is $L_1\cap L_2=\phi$?" is undecidable for context sensitive languages $L_1$ and $L_2$.

Statement II: The problem "Is $W\in L$?" is decidable for context sensitive language $L$, where $W$ is a string.

In the light of the above statements, choose the correct answer from the options given below:





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Nov 2020 (Paper II) PYQ

Solution

Statement I is true.

For context sensitive languages, the emptiness problem is undecidable.

Since context sensitive languages are closed under intersection, checking whether:

$L_1\cap L_2=\phi$

is also undecidable.

So, Statement I is true.

Statement II is also true.

Membership problem for context sensitive languages is decidable.

This is because context sensitive languages are accepted by Linear Bounded Automata, and for a fixed input there are only finitely many configurations.

Therefore, we can decide whether $W\in L$ or not.

So, both statements are true.

UGC NET Computer Science PYQ
Match List-I with List-II
 List-I

List-II 

 A. $A\rightarrow aB\ |\ a,\ a\in T,\ A,B\in V$
I. Recursive Descent Parser
 
 B. $A\rightarrow BC\ |\ a,\ a\in T,\ A,B,C\in V$
 II. Turing Machine
 C. $LL(1)$ grammar
 III. Chomsky Normal Form
 D. Halting problem

 IV. Finite Automata






Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science June 2024 (Paper II) PYQ

Solution

$A\rightarrow aB|a$ → Regular grammar → Finite Automata → IV


$A\rightarrow BC|a$ → Chomsky Normal Form → III


$LL(1)$ grammar → Recursive Descent Parser → I


Halting problem → Turing Machine → II


Matching:


$A\rightarrow IV$

$B\rightarrow III$

$C\rightarrow I$

$D\rightarrow II$


UGC NET Computer Science PYQ
In the context of Binding which one of the following is incorrect?





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Dec 2022 Shift I (Paper II) PYQ

Solution

Static binding is generally done at compile time.

Absolute addresses can be decided at load time.

In dynamic binding, target of a function may be known at runtime.

But internal functions are usually handled at compile time, not link time.

UGC NET Computer Science PYQ
In _____ curve the last and the first vertices of the polygon lie on the curve and all other vertices define the derivatives, order and shape of the curve.





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Dec 2022 Shift I (Paper II) PYQ

Solution

In a Bezier curve, the first and last control points lie on the curve.

The remaining control points control the shape, order and derivatives of the curve.

UGC NET Computer Science PYQ

Arrange the following Language Classes in ascending order according to their expressive power, as defined by Chomsky hierarchy.

(A) Context-free languages
(B) Context-sensitive languages
(C) Regular languages
(D) Unrestricted grammars






Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science August 2024 (Paper II) PYQ

Solution

Chomsky hierarchy order:


Regular Languages

< Context-Free Languages

< Context-Sensitive Languages

< Recursively Enumerable (Unrestricted) Languages


Thus order:


C → A → B → D


UGC NET Computer Science PYQ

Arrange the following Language Classes in ascending order according to their expressive power, as defined by Chomsky hierarchy.

(A) Context-free languages
(B) Context-sensitive languages
(C) Regular languages
(D) Unrestricted grammars






Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science August 2024 (Paper II) PYQ

Solution

Chomsky hierarchy order:


Regular Languages

< Context-Free Languages

< Context-Sensitive Languages

< Recursively Enumerable (Unrestricted) Languages


Thus order:


C → A → B → D


UGC NET Computer Science PYQ
Consider two lists A and B of three strings on $\{0,1\}$X:
List AList B
1111
1011110
100
Y:
List AList B
10101
01111
101011
Which of the following is true?





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Sep 2022 (Paper II) PYQ

Solution

PCP means Post Correspondence Problem.

In PCP, we have to choose the same sequence of indices from both lists such that the concatenation of strings from List A and List B becomes exactly equal.

First check list X.

List X pairs are:

$1:(1,111)$

$2:(10111,10)$

$3:(10,0)$

Try the sequence of indices:

$2,1,1,3$

Now concatenate strings from List A:

$10111\cdot 1\cdot 1\cdot 10$

$=101111110$

Now concatenate strings from List B using the same index sequence:

$10\cdot 111\cdot 111\cdot 0$

$=101111110$

Both strings are equal.

So, PCP in X has a solution.

Now check list Y.

List Y pairs are:

$1:(10,101)$

$2:(011,11)$

$3:(101,011)$

A valid PCP solution must start with a pair where the first symbols can match.

Only pair $1$ can start a possible match because:

List A gives $10$

List B gives $101$

Here, List B has one extra $1$ at the end.

So after choosing pair $1$, we have:

List A $=10$

List B $=101$

Now List B is ahead by extra $1$.

To balance it, the next string from List A must start with $1$.

Possible choices are pair $1$ or pair $3$.

If we choose pair $1$ again:

List A $=1010$

List B $=101101$

Here mismatch occurs.

If we choose pair $3$:

List A $=10101$

List B $=101011$

Again List B has extra $1$.

This same situation repeats, and equality is never obtained.

Pair $2$ cannot fix it because its List A string starts with $0$, while the required next symbol should match extra $1$.

Therefore, PCP in Y has no solution.

Hence, only PCP in X has solution.


UGC NET Computer Science PYQ
Consider the properties of recursively enumerable sets:

(A) Finiteness
(B) Context Freedom
(C) Emptiness
Which of the following is true?





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Sep 2022 (Paper II) PYQ

Solution

For recursively enumerable sets, these properties are related to languages accepted by Turing machines.

Now check each property one by one.

(A) Finiteness:

To decide whether a recursively enumerable language is finite or infinite, we need to know all strings accepted by the Turing machine.

But a Turing machine may not halt on some inputs.

So, finiteness of recursively enumerable sets is not decidable.

(B) Context Freedom:

To decide whether a recursively enumerable language is context-free or not is also not decidable.

This is a non-trivial property of the language accepted by a Turing machine.

By Rice's theorem, every non-trivial property of recursively enumerable languages is undecidable.

So, context freedom is not decidable.

(C) Emptiness:

Emptiness means checking whether the language accepted by a Turing machine is empty or not.

That is, we need to decide whether the Turing machine accepts at least one string.

This is also undecidable for recursively enumerable languages.

Therefore, all three properties are not decidable.

UGC NET Computer Science PYQ
Consider the following : 
List IList II
(A) Activation record(I) Linker Loader
(B) Location counter(II) Garbage Collection
(C) Reference count(III) Subroutine Call
(D) Address relocation(IV) Assembler
Which of the following is correct matching?





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Sep 2022 (Paper II) PYQ

Solution

Activation record is related to a subroutine call.

When a function or subroutine is called, an activation record is created to store information like parameters, return address and local variables.

So,

$(A)-(III)$

Location counter is used in assembler.

Assembler uses location counter to keep track of the address of the instruction or data item being assembled.

So,

$(B)-(IV)$

Reference count is related to garbage collection.

In reference counting, the system counts how many references point to an object. If the count becomes zero, that object can be removed.

So,

$(C)-(II)$

Address relocation is done by linker loader.

The linker loader adjusts addresses when a program is loaded into memory.

So,

$(D)-(I)$

Final matching is:

$(A)-(III), (B)-(IV), (C)-(II), (D)-(I)$

UGC NET Computer Science PYQ

Which data structure is used by the compiler for managing variables and their attributes?






Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science June 2019 (Paper II) PYQ

Solution

A compiler stores information about variables, functions, identifiers and their attributes in a symbol table.

Attributes may include name, type, scope, address and value.

Therefore, the data structure used for managing variables and their attributes is symbol table.


UGC NET Computer Science PYQ
On translating the expression given below into quadruple representation, how many operations are required?

$(ij)+(e+f)(a*b+c)$





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science June 2019 (Paper II) PYQ

Solution

Given expression is

$(ij)+(e+f)(a*b+c)$

Count each arithmetic operation:

$i*j$ gives $1$ operation.

$e+f$ gives $1$ operation.

$a*b$ gives $1$ operation.

$a*b+c$ gives $1$ operation.

$(e+f)(ab+c)$ gives $1$ operation.

Finally,

$(ij)+[(e+f)(a*b+c)]$ gives $1$ operation.

Total operations:

$1+1+1+1+1+1=6$


UGC NET Computer Science PYQ
Consider the grammar $S\to SbS\mid a$.

Consider the following statements:

The string $abababa$ has

(A) two parse trees

(B) two left most derivations

(C) two right most derivations

Which of the following is correct?





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Sep 2022 (Paper II) PYQ

Solution

Given grammar is:

$S\to SbS\mid a$

This grammar is ambiguous.

The string is:

$abababa$

It contains $4$ symbols $a$ and $3$ symbols $b$.

This is like combining four $a$'s using three $b$ operators.

Because the grammar does not define a fixed grouping rule, the string can be derived in more than one way.

For example, one possible grouping is:

$(((a)b(a))b(a))b(a)$

Another possible grouping is:

$(a)b((a)b((a)b(a)))$

So, the string has more than one parse tree.

For every different parse tree, there is a corresponding different left most derivation.

So, it has more than one left most derivation.

Similarly, for every different parse tree, there is a corresponding different right most derivation.

So, it has more than one right most derivation.

Therefore, all three statements are true in the sense of ambiguity.

UGC NET Computer Science PYQ

Replacing the expression $4*2.14$ by $8.56$ is known as:






Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science June 2019 (Paper II) PYQ

Solution

Constant folding is a compiler optimization technique.

In this technique, constant expressions are evaluated at compile time.

Here,

$4*2.14=8.56$

So, replacing $4*2.14$ by $8.56$ is constant folding.


UGC NET Computer Science PYQ
Consider the Grammar :

$S \rightarrow A$
$A \rightarrow S B S \mid id$
$B \rightarrow B, A \mid A$

If $I_0 = CLOSURE({[S' \rightarrow .A]})$, then how many items be in the set for $GOTO(I_0, S)$





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science August 2024 (Paper II) PYQ

Solution

Initial item

$S' \rightarrow .A$

Closure adds productions of $A$

$A \rightarrow .SBS$
$A \rightarrow .id$

Now the item containing $S$ after dot:

$A \rightarrow .SBS$

Applying GOTO on $S$ gives

$A \rightarrow S.BS$

Now closure for $B$ adds

$B \rightarrow .B,A$
$B \rightarrow .A$

Also expand $A$

$A \rightarrow .SBS$
$A \rightarrow .id$

Total items in $GOTO(I_0,S)$ = 4

UGC NET Computer Science PYQ

Shift-reduce parser consists of:

$(a)$ Input buffer
$(b)$ Stack
$(c)$ Parse table

Choose the correct option from those given below:






Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science June 2019 (Paper II) PYQ

Solution

A shift-reduce parser uses an input buffer to read the input string.

It uses a stack to store grammar symbols during parsing.

In table-driven shift-reduce parsing, a parse table is also used to decide shift and reduce actions.

Therefore, shift-reduce parser consists of input buffer, stack and parse table.


UGC NET Computer Science PYQ

How many states are there in a minimum state automata equivalent to regular expression given below?

Regular expression is $a^*b(a+b)$






Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science June 2019 (Paper II) PYQ

Solution

The regular expression is

$a^*b(a+b)$

It means:

Any number of $a$'s, followed by one $b$, followed by either $a$ or $b$.

So, strings accepted are like:

$ba,\ bb,\ aba,\ abb,\ aaba,\ aabb$

Minimum DFA states needed:

State $q_0$: Initial state, reads any number of $a$'s.
State $q_1$: After reading required $b$.
State $q_2$: Final state after reading last symbol $a$ or $b$.
State $q_d$: Dead state for extra or invalid symbols.

Thus, total minimum states are

$4$


UGC NET Computer Science PYQ
FFTs are ______ techniques used to encode digital video and audio information and helps analyse the signal in ____ domain.





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Dec 2022 Shift I (Paper II) PYQ

Solution

FFT stands for Fast Fourier Transform.

It is used in compression techniques and helps analyze signals in the frequency domain.

UGC NET Computer Science PYQ
Match List-I with List-II:
List-I List-II
(a) $\overline{L_3}\cup L_4$ (i) Context-free language
(b) $\overline{L_2}\cup L_3$ (ii) Recursively enumerable language
(c) $L_1^*\cap L_2$ (iii) Recursive language
where $L_1$: Regular language $L_2$: Context-free language $L_3$: Recursive language $L_4$: Recursively enumerable language Choose the correct option from those given below:





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science June 2019 (Paper II) PYQ

Solution

For $(a)$:

$L_3$ is a recursive language.

Complement of a recursive language is also recursive.

So,

$\overline{L_3}$ is recursive.

Also, $L_4$ is recursively enumerable.

Union of a recursive language and a recursively enumerable language is recursively enumerable.

Therefore,

$\overline{L_3}\cup L_4$ is recursively enumerable.

So,

$(a)\rightarrow(ii)$

For $(b)$:

$L_2$ is context-free language.

Every context-free language is recursive.

So, complement of $L_2$ is also recursive.

Also, $L_3$ is recursive.

Union of two recursive languages is recursive.

Therefore,

$\overline{L_2}\cup L_3$ is recursive.

So,

$(b)\rightarrow(iii)$

For $(c)$:

$L_1$ is regular.

Regular languages are closed under Kleene star.

So,

$L_1^*$ is regular.

Intersection of a regular language and a context-free language is context-free.

Therefore,

$L_1^*\cap L_2$ is context-free.

So,

$(c)\rightarrow(i)$

Hence, correct matching is

$(a)-(ii);\ (b)-(iii);\ (c)-(i)$


UGC NET Computer Science PYQ
In Pumping Lemma for context-free languages, to say a language is satisfying pumping lemma, what is the minimum length of $vx$ together, if you consider the string as $uvwxy$?





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Dec 2022 Shift I (Paper II) PYQ

Solution

For context-free language pumping lemma,

$string = uvwxy$

Conditions are:

$|vwx|\le n$

$|vx|\ge 1$

Here, $v$ and $x$ cannot both be empty.

So, minimum length of $vx$ together is:

$1$

UGC NET Computer Science PYQ

How can the decision algorithm be constructed for deciding whether context-free language $L$ is finite?

$(a)$ By constructing redundant CFG $G$ in CNF generating language $L$

$(b)$ By constructing non-redundant CFG $G$ in CNF generating language $L$

$(c)$ By constructing non-redundant CFG $G$ in CNF generating language $L-{\Lambda}$, where $\Lambda$ stands for null

Which of the following is correct?






Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science June 2019 (Paper II) PYQ

Solution

To decide whether a context-free language is finite or infinite, we can convert the CFG into a non-redundant CFG in CNF.

Usually, the CNF grammar is considered for $L-{\Lambda}$.

After converting into CNF, we check whether there is any recursive derivation or cycle among variables.

If such a recursive structure exists, then the language is infinite.

If no such recursive structure exists, then the language is finite.

So, the correct construction is given in statement $(c)$.


UGC NET Computer Science PYQ
Which of the following is $\epsilon$-free grammar?





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Dec 2022 Shift I (Paper II) PYQ

Solution

In standard grammar classification, Type-$1$ grammar is context-sensitive grammar.

Context-sensitive grammar is generally $\epsilon$-free because productions do not reduce the length of strings.

So, correct option should be:

$\boxed{(b)\ \text{Type-}1}$

UGC NET Computer Science PYQ

Consider the following grammar:

$S\to XY$

$X\to YaY\mid a$

$Y\to bbX$

Which of the following statements is/are true about the above grammar?

$(a)$ Strings produced by the grammar can have consecutive three $a$'s.

$(b)$ Every string produced by the grammar has alternate $a$ and $b$.

$(c)$ Every string produced by the grammar has at least two $a$'s.

$(d)$ Every string produced by the grammar has $b$'s in multiple of $2$.






Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science June 2019 (Paper II) PYQ

Solution

Given grammar is

$S\to XY$

$X\to YaY\mid a$

$Y\to bbX$

Since $S\to XY$, the string contains one part from $X$ and one part from $Y$.

Now, $X$ can generate at least one $a$.

Also, $Y\to bbX$, so $Y$ also contains one $X$, which again gives at least one $a$.

Therefore, every string generated by $S$ has at least two $a$'s.

So, statement $(c)$ is true.

Also, every use of $Y$ contributes $bb$, that is $2$ occurrences of $b$.

So, the number of $b$'s is always in multiple of $2$.

Therefore, statement $(d)$ is true.

The grammar contains $bb$, so alternate $a$ and $b$ condition is false.

Also, consecutive three $a$'s are not necessarily produced.


UGC NET Computer Science PYQ
While processing a string by an LR parser, the reading of the given string by the parser is-





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Dec 2022 Shift I (Paper II) PYQ

Solution

LR parser means:

$L =$ Left to right scanning

$R =$ Rightmost derivation in reverse

So, the parser reads the input string from left to right.

So, correct option is:

$\boxed{(b)\ \text{From left to right}}$

UGC NET Computer Science PYQ
Which protocol is used to acquire the MAC Address of a host whose IP address is known?





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Dec 2022 Shift I (Paper II) PYQ

Solution

ARP is used to find the MAC address when the IP address is known.

ARP stands for Address Resolution Protocol.

So, correct option is:

$\boxed{(b)\ \text{Address Resolution Protocol}}$

UGC NET Computer Science PYQ
Match List I with List II:
List IList II
(A) Type 0(I) Finite Automata
(B) Type 1(II) Turing Machine
(C) Type 2(III) Linear bound Automata
(D) Type 3(IV) Pushdown Automata
Choose the correct answer from the options given below:





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Sep 2022 (Paper II) PYQ

Solution

This question is based on Chomsky hierarchy.

In Chomsky hierarchy:

Type $0$ grammar is unrestricted grammar.

It is accepted by Turing Machine.

So,

$(A)-(II)$

Type $1$ grammar is context sensitive grammar.

It is accepted by Linear Bounded Automata.

So,

$(B)-(III)$

Type $2$ grammar is context free grammar.

It is accepted by Pushdown Automata.

So,

$(C)-(IV)$

Type $3$ grammar is regular grammar.

It is accepted by Finite Automata.

So,

$(D)-(I)$

Final matching is:

$(A)-(II), (B)-(III), (C)-(IV), (D)-(I)$

UGC NET Computer Science PYQ
For all real numbers $x$, there exists a real number $y$ such that $x$ is less than $y$.
(A) $L_1 = { w \in {0,1}^* \mid \text{length of } w \text{ is even} }$
(B) $L_2 = { w \in {0,1}^* \mid \text{length of } w \text{ is odd} }$
(C) $L_3 = { w \in {0,1}^* \mid \text{all 0s come before all 1s in } w }$
(D) $L_4 = { w \in {0,1}^* \mid w \text{ contains equal number of 0s and 1s} }$
(E) $L_5 = { w \in {0,1}^* \mid \text{all 1s come before all 0s in } w }$

Choose the correct answer from the options given below :





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science August 2024 (Paper II) PYQ

Solution

Important fact:

NFA and DFA recognize exactly the same class of languages → Regular Languages

So no language exists that can be recognized by NFA but not DFA.

But option (D)
equal number of 0s and 1s → not regular

Option (E)
all 1s before 0s → regular

Hence only (D) is non-regular.

Closest option given:

(4) (D) and (E) Only

UGC NET Computer Science PYQ

Consider the Grammar :

$T \rightarrow Qx$
$Q \rightarrow RS$
$R \rightarrow y \mid \varepsilon$
$S \rightarrow z \mid \varepsilon$

Here $x, y, z$ are terminals and $T, Q, R, S$ are non terminals.
What will be the follow set of the non terminal $R$ ?






Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science August 2024 (Paper II) PYQ

Solution

From production

$Q \rightarrow RS$

FOLLOW of $R$ includes FIRST of $S$ except $\varepsilon$

FIRST($S$) = ${z, \varepsilon}$

So add $z$

Since $S \rightarrow \varepsilon$, also include FOLLOW($Q$)

From

$T \rightarrow Qx$

FOLLOW($Q$) = ${x}$

Thus

FOLLOW($R$) = ${z, x}$

UGC NET Computer Science PYQ

 Consider the following grammars:

$G_1:S\rightarrow aSb\mid bSa\mid aa$

$G_2:S\rightarrow aSb\mid bSa\mid SS\mid \lambda$

$G_3:S\rightarrow aSb\mid bSa\mid SS\mid a$

$G_4:S\rightarrow aSb\mid bSa\mid SS\mid SSS\mid \lambda$

Which of the following is correct w.r.t. the above grammars?






Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Dec 2019 (Paper II) PYQ

Solution

In $G_2$, productions are:

$S\rightarrow aSb\mid bSa\mid SS\mid \lambda$

In $G_4$, productions are:

$S\rightarrow aSb\mid bSa\mid SS\mid SSS\mid \lambda$

The only extra production in $G_4$ is:

$S\rightarrow SSS$

But this production is already possible using $S\rightarrow SS$ again and again.

For example:

$S\rightarrow SS\rightarrow SSS$

So, $SSS$ does not generate anything extra.

Hence, $G_2$ and $G_4$ generate the same language.


UGC NET Computer Science PYQ
Consider the language $L={a^n b^{n-3}\mid n>2}$ on $\Sigma={a,b}$. Which one of the following grammars generates the language $L$?





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Dec 2019 (Paper II) PYQ

Solution

Given language is:

$L={a^n b^{n-3}\mid n>2}$

When $n=3$:

$a^3b^0=aaa$

When $n=4$:

$a^4b^1=aaaab$

When $n=5$:

$a^5b^2=aaaaabb$

So, every string starts with at least three $a$ symbols.

After that, for every extra $a$, one $b$ is added at the end.

Grammar:

$S\rightarrow aaaA$

$A\rightarrow aAb\mid \lambda$

If $A\rightarrow \lambda$, then string is:

$aaa$

If $A\rightarrow aAb$, then it generates:

$aaaab,\ aaaaabb,\ldots$

So, this grammar generates $a^n b^{n-3}$ for $n>2$.


UGC NET Computer Science PYQ

Consider the following grammar:

$S\rightarrow 0A\mid 0BB$

$A\rightarrow 00A\mid \lambda$

$B\rightarrow 1B\mid 11C$

$C\rightarrow B$

Which language does this grammar generate?






Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Dec 2019 (Paper II) PYQ

Solution

From production:

$S\rightarrow 0A$

and

$A\rightarrow 00A\mid \lambda$

So, $A$ can generate:

$\lambda,\ 00,\ 0000,\ldots$

Hence, $S$ generates:

$0,\ 000,\ 00000,\ldots$

This is represented by:

$(00)^*0$

Now consider:

$S\rightarrow 0BB$

But $B$ has productions:

$B\rightarrow 1B\mid 11C$

and

$C\rightarrow B$

Here, $B$ never terminates into $\lambda$ or any final terminal-only string.

So, this branch does not generate any valid finite string.

Hence, the grammar generates only:

$L((00)^*0)$


UGC NET Computer Science PYQ

Consider $\Sigma={w,x}$ and $T={x,y,z}$. Define homomorphism $h$ by:

$h(x)=xzy$

$h(w)=zxyy$

If $L$ is the regular language denoted by $r=(w+x^)(ww)^$, then the regular language $h(L)$ is given by:






Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Dec 2019 (Paper II) PYQ

Solution


UGC NET Computer Science PYQ
Consider the following statements:

Statement I: LALR parser is more powerful than canonical LR Parser.

Statement II: SLR parser is more powerful than LALR.

Which of the following is correct?





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Sep 2022 (Paper II) PYQ

Solution

The power hierarchy of LR parsers is:

$SLR < LALR < Canonical\ LR$

Now check Statement I:

Statement I says that LALR parser is more powerful than canonical LR Parser.

But actually Canonical LR parser is more powerful than LALR parser.

So, Statement I is false.

Now check Statement II:

Statement II says that SLR parser is more powerful than LALR.

But actually LALR parser is more powerful than SLR parser.

So, Statement II is false.

Therefore, both Statement I and Statement II are false.

UGC NET Computer Science PYQ

Consider the following statements with respect to the language $L={a^n b^n\mid n\ge 0}$

$S_1:L^2$ is context free language

$S_2:L^k$ is context-free language for any given $k\ge 1$

$S_3:\overline{L}$ and $L^*$ are context free languages

Which one of the following is correct?






Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Dec 2019 (Paper II) PYQ

Solution

Given language:

$L={a^n b^n\mid n\ge 0}$

This is a context free language.

Now check each statement.

For $S_1$:

$L^2=L\cdot L$

Context free languages are closed under concatenation.

So, $L^2$ is also context free.

Hence, $S_1$ is true.

For $S_2$:

$L^k$ means concatenation of $L$ with itself $k$ times.

For any fixed $k\ge 1$, context free languages are closed under finite concatenation.

So, $L^k$ is context free.

Hence, $S_2$ is true.

For $S_3$:

$L^*$ is context free because context free languages are closed under Kleene star.

Also, for this specific language $L={a^n b^n\mid n\ge 0}$, its complement $\overline{L}$ is also context free.

So, $\overline{L}$ and $L^*$ both are context free languages.

Hence, $S_3$ is true.

Therefore, all three statements $S_1,\ S_2$ and $S_3$ are correct.


UGC NET Computer Science PYQ
Consider the following statements about Context Free Language (CFL):

Statement I: CFL is closed under homomorphism.

Statement II: CFL is closed under complement.

Which of the following is correct?





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Sep 2022 (Paper II) PYQ

Solution

Statement I:

Context Free Languages are closed under homomorphism.

It means if a language is context free, then its homomorphic image is also context free.

So, Statement I is true.

Statement II:

Context Free Languages are not closed under complement.

This means if $L$ is a CFL, then complement of $L$ may not be a CFL.

So, Statement II is false.

Therefore, Statement I is true and Statement II is false.

UGC NET Computer Science PYQ

Consider the following languages:

$L_1={a^n b^n c^m}\cup{a^n b^m c^m},\ n,m\ge 0$

$L_2={ww^R\mid w\in{a,b}^*}$ where $R$ represents reversible operation.

Which one of the following is/are inherently ambiguous language(s)?






Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Dec 2019 (Paper II) PYQ

Solution

$L_1={a^n b^n c^m}\cup{a^n b^m c^m}$ is a standard example of an inherently ambiguous language.

Reason: strings of the form $a^n b^n c^n$ can be generated from both parts:

First part: $a^n b^n c^m$ when $m=n$

Second part: $a^n b^m c^m$ when $m=n$

So, ambiguity is unavoidable for $L_1$.

Now,

$L_2={ww^R\mid w\in{a,b}^*}$ is the language of even length palindromes.

This language is context-free and not inherently ambiguous.


UGC NET Computer Science PYQ

Let $G=(V,T,S,P)$ be any context-free grammar without any $\lambda$-productions or unit productions. Let $K$ be the maximum number of symbols on the right of any production in $P$. The maximum number of production rules for any equivalent grammar in Chomsky normal form is given by:

Where $|\ |$ denotes the cardinality of the set.






Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Dec 2019 (Paper II) PYQ

Solution

In Chomsky Normal Form, every production must be of the form:

$A\rightarrow BC$

or

$A\rightarrow a$

If a production has maximum $K$ symbols on the right side, then to convert it into binary productions, at most $K-1$ productions are needed.

So, for $|P|$ productions, maximum productions required are:

$(K-1)|P|$

Also, for terminals, we may need separate productions for each terminal.

Number of terminals $=|T|$

So, total maximum number of productions:

$(K-1)|P|+|T|$


UGC NET Computer Science PYQ

 Consider the following language families:

$L_1\equiv$ The context-free languages

$L_2\equiv$ The context-sensitive languages

$L_3\equiv$ The recursively enumerable languages

$L_4\equiv$ The recursive languages

Which one of the following options is correct?






Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Dec 2019 (Paper II) PYQ

Solution

The Chomsky hierarchy and decidability relation is:

Context-free languages $\subseteq$ Context-sensitive languages

Context-sensitive languages $\subseteq$ Recursive languages

Recursive languages $\subseteq$ Recursively enumerable languages

So,

$L_1\subseteq L_2\subseteq L_4\subseteq L_3$


UGC NET Computer Science PYQ

Consider the following statements:

$S_1:$ There exists no algorithm for deciding if any two Turing machines $M_1$ and $M_2$ accept the same language.

$S_2:$ Let $M_1$ and $M_2$ be arbitrary Turing machines. The problem to determine $L(M_1)\subseteq L(M_2)$ is undecidable.

Which of the statements is/are correct?






Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Dec 2019 (Paper II) PYQ

Solution

Checking whether two Turing machines accept the same language means checking:

$L(M_1)=L(M_2)$

This is undecidable.

So, $S_1$ is true.

For $S_2$:

Checking whether:

$L(M_1)\subseteq L(M_2)$

for arbitrary Turing machines is also undecidable.

So, $S_2$ is also true.


UGC NET Computer Science PYQ
 Let $A={001,0011,11,101}$ and $B={01,111,111,010}$. Similarly, let $C={00,001,1000}$ and $D={0,11,011}$. Which of the following pairs have a post-correspondence solution?





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Dec 2019 (Paper II) PYQ

Solution

For pair $(A,B)$:

Take sequence of indices:

$3,4,1$

From $A$ side:

$A_3A_4A_1=11\ 101\ 001=11101001$

From $B$ side:

$B_3B_4B_1=111\ 010\ 01=11101001$

Both strings are equal.

So, pair $(A,B)$ has a PCP solution.

For pair $(C,D)$:

Starting must be with first pair because only it gives matching prefix:

$C_1=00,\ D_1=0$

After this, extra $0$ remains on upper side. Repeating first pair keeps increasing extra zeros, and other pairs do not match the required prefix properly.

So, pair $(C,D)$ has no PCP solution.


UGC NET Computer Science PYQ
Given below are two statements: one is labelled as Assertion (A) and the other is labelled as Reason (R):

Assertion (A): A load-and-go assembler avoids the overhead of writing the object program out and reading it back in.

Reason (R): This can be done with either one-pass or two pass assembler.

In the light of the above statements, choose the correct answer from the options given below:





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Sep 2022 (Paper II) PYQ

Solution

Assertion (A):

A load-and-go assembler directly loads the translated machine code into memory for execution.

It does not create a separate object program file first.

So, it avoids two extra steps:

Writing the object program out

Reading the object program back in

Therefore, Assertion (A) is true.

Reason (R):

A load-and-go assembler can be implemented using one-pass assembler or two-pass assembler technique.

So, Reason (R) is also true.

But Reason (R) only tells that load-and-go can be done using one-pass or two-pass assembler.

It does not explain why the overhead of writing and reading the object program is avoided.

The overhead is avoided because the object code is loaded directly into memory.

Therefore, both (A) and (R) are true, but (R) is not the correct explanation of (A).

UGC NET Computer Science PYQ
Which statement is false?





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Sep 2022 (Paper II) PYQ

Solution

Check option (a):

In C language, function arguments are passed by value.

It means a copy of the actual argument is passed to the function.

So, option (a) is true.

Check option (b):

Call by reference allows a function to modify the original variable of the calling function.

So, option (b) is true.

Check option (c):

Call by value is not always more efficient than call by reference.

For large data structures, passing by reference or using pointers can be more efficient because copying large data is avoided.

So, option (c) is false.

Check option (d):

C does not directly support call by reference.

But programmers use pointers and indirection operators to simulate call by reference.

So, option (d) is true.

Therefore, the false statement is option (c).

UGC NET Computer Science PYQ

Which of the following Finite Automata,

recognizes the language L = {a , b}* ?
A. $M=({q_0},{a,b},\delta,q_0,{q_0})$ where, $\delta$ is







Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Dec 2022 Shift I (Paper II) PYQ

Solution

The language $L={a,b}^*$ means all possible strings over $a$ and $b$, including null string $\epsilon$.


So, an automaton recognizes $L={a,b}^*$ if every string made from $a$ and $b$ is accepted.


In A, $q_0$ is the initial and final state, and both $a$ and $b$ return to $q_0$.


So, A accepts all strings over ${a,b}$.


In B and C, $q_0$ and $q_1$ are final states, so all possible moves remain in final states.


So, B and C also accept all strings over ${a,b}$.


In D, $q_0$ is final and from $q_0$, both $a$ and $b$ return to $q_0$. Other states do not affect acceptance because starting from $q_0$, every input stays at $q_0$.


So, D also accepts all strings over ${a,b}$.


Therefore, A, B, C and D recognize $L={a,b}^*$.


UGC NET Computer Science PYQ
Which of the following statement(s) are correct?
A. Syntax Directed Translation can be applied in Type Checking.
B. Syntax Directed Translation can be used in 3-address code generation.
C. Syntax Directed Translation can be used in construction of syntax tree.
D. Syntax Directed Translation can be used to recognize valid tokens.





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Dec 2022 Shift I (Paper II) PYQ

Solution

Syntax Directed Translation is used in:

Type checking

Intermediate code generation like 3-address code

Construction of syntax tree

But valid tokens are recognized by lexical analyzer, not by syntax directed translation.

So, correct statements are A, B and C.

Correct option is:

$\boxed{(a)\ \text{A, B and C}}$


UGC NET Computer Science PYQ
Which of the following statement(s) are correct?
A. Syntax Directed Translation can be applied in Type Checking.
B. Syntax Directed Translation can be used in 3-address code generation.
C. Syntax Directed Translation can be used in construction of syntax tree.
D. Syntax Directed Translation can be used to recognize valid tokens.





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Dec 2022 Shift I (Paper II) PYQ

Solution

Given distance from router $R$ to its neighbors:

$R\to X=3$

$R\to Y=2$

$R\to Z=5$

For router $P$:

Via $X$: $3+7=10$

Via $Y$: $2+6=8$

Via $Z$: $5+5=10$

Minimum distance from $R$ to $P$ is $8$ via $Y$.

So, statement C is true.

For router $Q$:

Via $X$: $3+4=7$

Via $Y$: $2+6=8$

Via $Z$: $5+8=13$

Minimum distance from $R$ to $Q$ is $7$ via $X$.

So, statement B is true.

Correct statements are B and C only.

Correct option is:

$\boxed{(a)\ \text{B and C only}}$


UGC NET Computer Science PYQ

Which of the following tasks could be attained using syntax trees in compiler design ?

(A) Type Checking
(B) Code Generation
(C) Code Optimization
(D) Error Handling

Choose the correct answer from the options given below :






Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science August 2024 (Paper II) PYQ

Solution

Syntax trees (Abstract Syntax Tree – AST) are used in later compiler phases.


(A) Type Checking → Done using syntax tree ✔


(B) Code Generation → Uses syntax tree ✔


(C) Code Optimization → Uses syntax tree representation ✔


(D) Error Handling → Mainly done during lexical / syntax analysis ✘


Thus correct tasks:


(A), (B), (C)


UGC NET Computer Science PYQ
Match List I with List II
 List I

 List II

A. Initial Configuration of stack and input in the LL Parsing process

I. $w$

B. Final Configuration of stack and input in LL Parsing process

$$

C. Initial Configuration of stack and input in the LR Parsing process

S w

D. Final Configuration of stack and input in LR Parsing process

S

Choose the correct answer from the options given below:






Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Dec 2022 Shift I (Paper II) PYQ

Solution

For LL parsing:

Initial configuration: $$S w$$

Final configuration: $$$$

For LR parsing:

Initial configuration: $$w$$

Final configuration: $$S$$

So,

A → III
B → II
C → I
D → IV

Correct option is:

$\boxed{(b)\ A-III,\ B-II,\ C-I,\ D-IV}$


UGC NET Computer Science PYQ
Arrange the following stages of parsing in the correct order as they typically occur in the compilation process.

(A) Lexical Analysis
(B) Semantic Analysis
(C) Syntax Analysis
(D) Intermediate Code Generation
(E) Code Optimization

Choose the correct answer from the options given below :





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science August 2024 (Paper II) PYQ

Solution

Standard compiler phases:


Lexical Analysis


Syntax Analysis


Semantic Analysis


Intermediate Code Generation


Code Optimization


Thus order:


(A) → (C) → (B) → (D) → (E)


UGC NET Computer Science PYQ
Consider the following DFA that generates set of strings over Σ = {a, b, c}.
Identify the best description of the language for the DFA.





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science 26 June 2025 (Paper II) PYQ

Solution

The automaton has two “phases” connected by the path recognizing a→b→c. Each time the substring “abc” is seen, the DFA moves to the other phase, toggling parity. The start phase (no “abc” yet) is accepting (count 0), and after every additional “abc” the parity flips; therefore the accepting states correspond to an even number of occurrences of “abc”. Options 1 and 2 describe Σ* (all strings), and option 3 does not match the transitions.

UGC NET Computer Science PYQ
The precedence of regular expression operators from lowest to highest precedence is:





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Dec 2022 Shift I (Paper II) PYQ

Solution

In regular expressions, operator precedence from highest to lowest is:

$Star > Concatenation > Union$

Therefore, from lowest to highest:

$Union < Concatenation < Star$

Correct option is:

$\boxed{(c)\ \text{Union, Concatenation, Star}}$


UGC NET Computer Science PYQ

Which of the following properties correctly describe a Regular Grammar ?

(A) All productions rules are of the form $A \rightarrow xB$ or $A \rightarrow x$, where $A$ and $B$ are non terminal symbols and $x$ is a terminal symbol.

(B) Regular grammars are more powerful than context-free grammars and can express any type of language.

(C) There is a direct correspondence between regular grammar and finite automata.

(D) Regular grammars can generate languages that are not recognised by any type of automata.

Choose the correct answer from the options given below :






Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science August 2024 (Paper II) PYQ

Solution

(A) True

Regular grammar productions follow


$A \rightarrow aB$ or $A \rightarrow a$


(B) False

Regular grammar less powerful than CFG


(C) True

Regular grammar ↔ Finite automata equivalence


(D) False

Regular languages are recognized by finite automata


UGC NET Computer Science PYQ
Which of the following languages are not regular?

A. $L=\{(01)^n0^k\mid n>k,\ k\ge 0\}$

B. $L=\{c^nb^ka^{n+k}\mid n\ge 0,\ k\ge 0\}$

C. $L=\{0^n1^k\mid n\ne k\}$

Choose the correct answer from the options given below:





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Nov 2021 (Paper II) PYQ

Solution


Language A compares the number of $(01)$ blocks with the number of ending $0$ symbols.

This counting comparison cannot be done by a finite automaton, so A is not regular.

Language B has form $c^nb^ka^{n+k}$.

Here, number of $a$ symbols depends on the sum of number of $c$ and $b$ symbols.

A finite automaton cannot store this count, so B is not regular.

Language C is $L=\{0^n1^k\mid n\ne k\}$.

If C were regular, then its complement within $0^*1^*$ would also be regular.

But that complement is $\{0^n1^n\}$, which is not regular.

So, C is also not regular.

Therefore, A, B and C are not regular.

UGC NET Computer Science PYQ
Any string of terminals that can be generated by the following context-free grammar, where $S$ is start nonterminal symbol

$S\to XY$

$X\to 0X\mid 1X\mid 0$

$Y\to Y0\mid Y1\mid 0$





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Nov 2021 (Paper II) PYQ

Solution

From $X\to 0X\mid 1X\mid 0$, $X$ generates any binary string ending with $0$.

So, $X=(0+1)^*0$.

From $Y\to Y0\mid Y1\mid 0$, $Y$ generates any binary string starting with $0$.

So, $Y=0(0+1)^*$.

Now,

$S\to XY$

So, every string generated by $S$ contains one $0$ from the end of $X$ and one $0$ from the start of $Y$.

Therefore, every generated string has at least two $0$'s.

UGC NET Computer Science PYQ

Consider the following statements:

A. For every regular language, we can design Turing Machine.

B. For every context free language, we can design Turing Machine.

Which of the following is correct?






Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Dec 2022 Shift I (Paper II) PYQ

Solution

Every regular language can be accepted by a finite automaton, and every finite automaton can be simulated by a Turing Machine.

So, statement A is true.

Every context free language can be accepted by a pushdown automaton, and every pushdown automaton can also be simulated by a Turing Machine.

So, statement B is also true.

Correct option is:

$\boxed{(d)\ \text{Statement A and Statement B both are true}}$


UGC NET Computer Science PYQ
Let

$L_1=\{0^n1^n0^m\mid n\ge 1,\ m\ge 1\}$

$L_2=\{0^n1^m0^m\mid n\ge 1,\ m\ge 1\}$

$L_3=\{0^n1^n0^n\mid n\ge 1\}$

Which of the following are correct statements?

A. $L_3=L_1\cap L_2$

B. $L_1$ and $L_2$ are context free languages but $L_3$ is not a context free language

C. $L_1$ and $L_2$ are not context free languages but $L_3$ is a context free language

D. $L_1$ is a subset of $L_3$

Choose the correct answer from the options given below:





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Nov 2021 (Paper II) PYQ

Solution

$L_1$ has equal number of first $0$'s and $1$'s, so it is CFL.

$L_2$ has equal number of $1$'s and last $0$'s, so it is also CFL.

Now,

$L_1=\{0^n1^n0^m\}$

$L_2=\{0^n1^m0^m\}$

In $L_1\cap L_2$, number of first $0$'s $=$ number of $1$'s and number of $1$'s $=$ number of last $0$'s.

So,

$L_1\cap L_2=\{0^n1^n0^n\}=L_3$

Thus, statement A is true.

$L_3=\{0^n1^n0^n\mid n\ge 1\}$ is not context free language.

So, statement B is true.

Statement C is false because $L_1$ and $L_2$ are CFL.

Statement D is false because $L_1$ contains strings like $0011000$, which are not in $L_3$.

UGC NET Computer Science PYQ

Which of the following are context free language ?


(A) ${w^i x^j y^k z^l \mid i + k = j + l,; i,j,k,l \ge 0}$


(B) ${w^i x^j y^k z^l \mid i = j \text{ and } k = l,; i,j,k,l \ge 0}$


(C) ${w^i x^j y^k z^l \mid i = j = k \text{ and } k \ne l,; i,j,k,l \ge 0}$


(D) ${w^i x^j y^k z^l \mid i = j = k + l,; i,j,k,l \ge 0}$


(E) ${w^i x^j y^k z^l \mid i = j \text{ and } k \ne l,; i,j,k,l \ge 0}$


Choose the correct answer from the options given below :






Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science August 2024 (Paper II) PYQ

Solution

(A) Condition $ i + k = j + l $ This type of dependency is not context free (requires two independent balances). So not CFL. (B) Conditions $ i = j $ and $ k = l $ Language form $ w^i x^i y^k z^k $ This is context free. (C) Condition $ i = j = k $ This is similar to $ a^n b^n c^n $ which is not context free. (D) Condition $ i = j = k + l $ Single dependency handled by PDA → Context Free. (E) Condition $ i = j $ and $ k \ne l $ Still context free (difference condition allowed). Correct CFL: (D) and (E)

UGC NET Computer Science PYQ
Given below are two statements

Statement I: The family of context free languages is closed under homomorphism.

Statement II: The family of context free languages is closed under reversal.

In light of the above statements, choose the correct answer from the options given below.





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Nov 2021 (Paper II) PYQ

Solution

Context free languages are closed under homomorphism.

So, if $L$ is CFL, then $h(L)$ is also CFL.

Therefore, Statement I is true.

Context free languages are also closed under reversal.

So, if $L$ is CFL, then $L^R$ is also CFL.

Therefore, Statement II is true.

Hence, both Statement I and Statement II are true.

UGC NET Computer Science PYQ
What is the minimum number of states required to the finite automaton equivalent to the transition diagram given below?





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Nov 2021 (Paper II) PYQ

Solution

In the given DFA, final states are $c$ and $g$.

First partition the states into final and non-final states:

$P_1=\{c,g\}$

$P_2=\{a,b,d,e,f,h\}$

Now minimize by checking equivalent states.

State $d$ is unreachable from the start state, so it can be ignored.

Among reachable states, equivalent groups are:

$\{a,e\}$

$\{b,h\}$

$\{f\}$

$\{c\}$

$\{g\}$

So, total minimum states are:

$5$

UGC NET Computer Science PYQ
Find the regular expression for the language accepted by the automata given below.





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Nov 2021 (Paper II) PYQ

Solution

Let the states be $q_0,q_1,q_2$.

Here, $q_0$ is start state and final state.

From the diagram:

$q_0\xrightarrow{a}q_1$

$q_1\xrightarrow{b}q_0$

$q_1\xrightarrow{a}q_2$

$q_2\xrightarrow{b}q_1$

$q_0\xrightarrow{b}q_2$

Now, paths from $q_0$ back to $q_0$ are:

$q_0\xrightarrow{a}q_1\xrightarrow{b}q_0$, giving $ab$

Also,

$q_0\xrightarrow{b}q_2\xrightarrow{b}q_1\xrightarrow{b}q_0$, giving $bbb$

In general, from $q_1$ to $q_0$ we can have:

$(ab)^*b$

So, complete cycle from $q_0$ to $q_0$ is:

$(a+bb)(ab)^*b$

Since $q_0$ is final, these cycles can repeat any number of times.

Required regular expression is:

$((a+bb)(ab)^*b)^*$

UGC NET Computer Science PYQ

If $L_1$ and $L_2$ are context free languages, which of the following is True about $L_1 \cap L_2$ ?






Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science August 2024 (Paper II) PYQ

Solution

Important theory result: Context Free Languages are NOT closed under intersection But intersection of CFLs is Context Sensitive Thus $ L_1 \cap L_2 $ belongs to Context Sensitive languages

UGC NET Computer Science PYQ
 What language is accepted by the pushdown automaton

$M=({q_0,q_1,q_2},\{a,b\},\{a,b,z\},\delta,q_0,z,\{q_2\})$

with

$\delta(q_0,a,a)=\{(q_0,aa)\}$

$\delta(q_0,b,a)=\{(q_0,ba)\}$

$\delta(q_0,a,b)=\{(q_0,ab)\}$

$\delta(q_0,b,b)=\{(q_0,bb)\}$

$\delta(q_0,a,z)=\{(q_0,az)\}$

$\delta(q_0,b,z)=\{(q_0,bz)\}$

$\delta(q_0,\lambda,b)=\{(q_1,b)\}$

$\delta(q_0,\lambda,a)=\{(q_1,a)\}$

$\delta(q_1,a,a)=\{(q_1,\lambda)\}$

$\delta(q_1,b,b)=\{(q_1,\lambda)\}$

$\delta(q_1,\lambda,z)=\{(q_2,z)\}$





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Nov 2021 (Paper II) PYQ

Solution

In state $q_0$, the PDA reads input symbols and pushes them into the stack.

So, first part of the string is stored in stack.

After that, using $\lambda$ move, PDA goes from $q_0$ to $q_1$.

In state $q_1$, the PDA reads input and matches it with the top of stack.

If input is $a$ and stack top is $a$, it pops $a$.

If input is $b$ and stack top is $b$, it pops $b$.

So, second part of the string must be reverse of the first part.

When stack reaches bottom symbol $z$, PDA goes to final state $q_2$.

Therefore, language accepted is even length palindrome over $\{a,b\}$.

So,

$L=\{ww^R\mid w\in\{a,b\}^+\}$

UGC NET Computer Science PYQ

Arrange the following stages of a Turing Machine (TM) operation in the correct order as they occur during computation.


(A) Writing a symbol on the tape


(B) Moving the tape head left or right


(C) Reading a symbol from the tape


(D) Transitioning to a new state based on the current state and symbol read


(E) Halting and accepting or rejecting the input


Choose the correct answer from the options given below :






Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science August 2024 (Paper II) PYQ

Solution

Typical Turing Machine step:

1 Read symbol
2 Decide next state
3 Write symbol
4 Move tape head
5 Halt condition

Thus order

(C) → (D) → (A) → (B) → (E)

UGC NET Computer Science PYQ
Match List I with List II
List IList II
A. $S\to XY,\ X\to 0,\ Y\to 1$I. Greibach Normal Form
B. $S\to aS\mid bSS\mid c$II. Context sensitive Grammar
C. $S\to AB,\ A\to 0A\mid 1A\mid 0,\ B\to 0A$III. Chomsky Normal Form
D. $S\to aAbc,\ Ab\to bA,\ Ac\to Bbcc,\ bB\to Bb,\ aB\to aa\mid aaA$IV. S-Grammar
Choose the correct answer from the options given below:





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Nov 2021 (Paper II) PYQ

Solution

For A, productions are of the form $A\to BC$ or $A\to a$, so it is Chomsky Normal Form. Hence, $A-III$.

For B, every production starts with a terminal symbol, so it is Greibach Normal Form. Hence, $B-I$.

For C, grammar is matched with S-Grammar. Hence, $C-IV$.

For D, some productions have more than one symbol on the left side, like $Ab\to bA$, and length is non-decreasing. So it is Context Sensitive Grammar. Hence, $D-II$.

Final matching is $A-III,\ B-I,\ C-IV,\ D-II$.

UGC NET Computer Science PYQ
Which of the following concepts can be used to identify loops?

A. Depth first ordering
B. Dominators
C. Reducible graphs
Choose the correct answer from the options given below:





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Nov 2021 (Paper II) PYQ

Solution

In compiler design, loops in a flow graph are commonly identified using depth first ordering and back edges.

Dominators are also used because a loop header dominates the nodes inside the loop.

Reducible graphs are important in loop analysis because loops in reducible flow graphs can be identified systematically.

So, all three concepts are useful for identifying loops.

UGC NET Computer Science PYQ
Given below are two statements

Statement I: LL(1) and LR are examples of Bottom-up parsers.

Statement II: Recursive descent parser and SLR are examples of Top-down parsers.

In light of the above statements, choose the correct answer from the options given below.





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Nov 2021 (Paper II) PYQ

Solution

LL(1) parser is a top-down parser, while LR parser is a bottom-up parser.

So, Statement I is false.

Recursive descent parser is a top-down parser, but SLR parser is a bottom-up parser.

So, Statement II is also false.

Hence, both statements are false.

UGC NET Computer Science PYQ

Match List I with List II

List I (Grammar Type) List II (Production Form)
A. Type 3 Grammar IV. $V \rightarrow V\Sigma \mid \Sigma$
B. Type 2 Grammar I. $V \rightarrow (V \cup \Sigma)^{*}$
C. Type 1 Grammar II. $\lambda A \beta \rightarrow \lambda\,\gamma\,\beta,\;(\lambda,\beta)\in (V\cup\Sigma)^{*}$
D. Type 0 Grammar III. $(V\cup\Sigma)^{*} \rightarrow (V\cup\Sigma)^{*}$





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science 26 June 2025 (Paper II) PYQ

Solution

Why: Type-3 (regular) → right-linear (IV); Type-2 (context-free) → $V \to (V\cup\Sigma)^*$ (I); Type-1 (context-sensitive) → context-preserving form (II); Type-0 (unrestricted) → any string to any string (III).


UGC NET Computer Science PYQ

Consider the following DFA

Which of the following NFA is valid for the given DFA?

(a) 

(b) 

(c) 






Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science 26 June 2025 (Paper II) PYQ

Solution



UGC NET Computer Science PYQ

The transition function $\delta$ in multi-tape Turing machine is defined as:






Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Dec 2022 Shift II (Paper II) PYQ

Solution

In a multi-tape Turing machine, suppose there are $k$ tapes.

At any step, the machine reads:

$k$ tape symbols

So, input to transition function is:

$current\ state = Q$

$k\ tape\ symbols = \Gamma^k$

Hence input side is:

$Q \times \Gamma^k$

After transition, the machine decides:

new state $Q$

new symbols to write on $k$ tapes, that is $\Gamma^k$

movement of $k$ tape heads, that is ${L,R,S}^k$

Hence output side is:

$Q \times \Gamma^k \times {L,R,S}^k$

Therefore,

$\delta: Q \times \Gamma^k \to Q \times \Gamma^k \times {L,R,S}^k$


UGC NET Computer Science PYQ
In Pumping Lemma for regular languages, to say a language is satisfying pumping lemma, what is the minimum length of $y$ if you consider the string as $xyz$?





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Dec 2022 Shift II (Paper II) PYQ

Solution

In pumping lemma for regular languages, a string is divided as:

$w=xyz$

The conditions are:

$|xy| \le n$

$|y| > 0$

$xy^iz \in L$ for all $i \ge 0$

Here, $|y|>0$ means $y$ cannot be empty.

So, the minimum length of $y$ is:

$1$


UGC NET Computer Science PYQ

The item generated by the production $A \to \epsilon$ is:






Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Dec 2022 Shift II (Paper II) PYQ

Solution

In LR item notation, a dot is placed somewhere on the right side of a production.

But $\epsilon$ means empty string.

So, for the production:

$A \to \epsilon$

there is actually no symbol on the right side.

Therefore, the LR item is written as:

$A \to .$

This means the production is already complete.


UGC NET Computer Science PYQ
Which of the following Grammars is/are only Context-Free?
LabelProductions Note
A S → Ab
aS → aA
A → a
LHS “aS” has a terminal → not CFG
B S → Ab
A → Sa
A → a
All rules are left-linear (V→Vt or V→t) → regular
C S → AS
S → aA
A → a
CFG, not regular (non-linear: V→VV)
D S → Ab
S → aA
A → a
CFG; mixes left/right-linear → not regular
E S → Sb
A → Aa
A → ε
From start S no terminal string → L(S)=∅ (regular)





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science 26 June 2025 (Paper II) PYQ

Solution

A is not even CFG (terminal on LHS).
B is a regular (left-linear) grammar.
C and D are context-free but not regular (“only” context-free).
E generates the empty language from start symbol S, which is regular.

UGC NET Computer Science PYQ
In the $\epsilon$-NFA, $M=({q_0,q_1,q_2,q_3},{a},\delta,q_0,{q_3})$ where $\delta$ is given in the transition table below, what is the minimum length of string to reach to the final state?
   $\epsilon$ 

$a$ 
 $q_0$ {$q_1$}{ } 
 $q_1${$q_2$}  { }
 $q_2${ } {$q_2 , $ $q_3$ }
 $q_3${} {} 






Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Dec 2022 Shift II (Paper II) PYQ

Solution

Initial state is:

$q_0$

From $q_0$, using $\epsilon$ move:

$q_0 \xrightarrow{\epsilon} q_1$

From $q_1$, again using $\epsilon$ move:

$q_1 \xrightarrow{\epsilon} q_2$

So, without reading any input symbol, we can reach:

$q_2$

But final state is:

$q_3$

Now from $q_2$, on input symbol $a$:

$q_2 \xrightarrow{a} {q_2,q_3}$

So, after reading one $a$, we can reach final state $q_3$.

Therefore, the minimum string is:

$a$

Length of $a$ is:

$1$


UGC NET Computer Science PYQ

Given a vector with cartesian components $(x,y)$, if scaling is done with matrix

$M=\left[\matrix{0.5\quad 0\cr 0\quad 1.5}\right]$

which of the following are true.

  1. Decreases the vertical by three halves
  2. Increases the vertical by three halves
  3. Doubles the horizontal
  4. Halves the horizontal

Choose the correct answer from the options given below:






Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Dec 2022 Shift II (Paper II) PYQ

Solution

Scaling matrix is:

$M=\left[\matrix{0.5\quad 0\cr 0\quad 1.5}\right]$

Here,

Horizontal scaling factor is:

$S_x=0.5=\frac{1}{2}$

So, horizontal value becomes half.

Therefore, statement $4$ is true.

Vertical scaling factor is:

$S_y=1.5=\frac{3}{2}$

So, vertical value increases by three halves.

Therefore, statement $2$ is true.

Correct statements are:

$2$ and $4$


UGC NET Computer Science PYQ

Which of the following is (are) correct about the regular expression?

a a* b b* c c* d d*

  1. The language for the given expression is:

$L={a^n b^n c^m d^m \mid n\ge 1,\ m\ge 1}\cup{a^n b^m c^m d^n \mid n\ge 1,\ m\ge 1}$

  1. The Context Free Language for the given expression is:

$S\to AB\mid C$

$A\to aAb\mid ab$

$B\to cBd\mid cd$

$C\to aCd\mid aDd$

$D\to bDc\mid bc$

  1. The language generated by this expression is equal number of $a$'s, followed by equal number of $b$'s, followed by equal number of $c$'s and followed by equal number of $d$'s.

Choose the correct answer from the options given below:






Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Dec 2022 Shift II (Paper II) PYQ

Solution

The given regular expression is $aa^*bb^*cc^dd^$, where:

  • $a^*$ denotes zero or more occurrences of $a$
  • $b^*$ denotes zero or more occurrences of $b$
  • $c^*$ denotes zero or more occurrences of $c$
  • $d^*$ denotes zero or more occurrences of $d$
  1. The language generated by the regular expression

$L={a^n b^n c^m d^m \mid n \ge 1, m \ge 1}\cup{a^n b^m c^m d^n \mid n \ge 1, m \ge 1}$

consists of strings where $a$'s are followed by $b$'s, which are followed by $c$'s, and then $d$'s.

Each of these letters $a, b, c, d$ can occur one or more times in any order. For example, $abcd$, $aabcdd$, etc. So the language $L$ can generate regular expressions $aa^*bb^*cc^dd^$.

  1. The Context Free Language for the given expression is:

$S \to AB \mid C$

$A \to aAb \mid ab$

$B \to cBd \mid cd$

$C \to aCd \mid aDd$

$D \to bDc \mid bc$

This is true.

For example:

$S \to AB \mid C$

$S \to abcd$

  1. The language generated by this expression is equal number of $a$'s, followed by equal number of $b$'s, followed by equal number of $c$'s and followed by equal number of $d$'s.

This statement is false.

The regular expression $aa^*bb^*cc^dd^$ generates strings where each letter $a, b, c, d$ can occur one or more times, but there is no constraint that the number of occurrences of each letter must be equal.

For example, the regular expression can generate strings like $abcd$, $abccdd$, $aaaabbbccddd$, etc., where the number of occurrences of each letter is not necessarily equal.

So option C is the correct answer.


UGC NET Computer Science PYQ

Which of the following statements are correct?

  1. The first three-address instruction in the intermediate code is a leader.
  2. The instruction which is exactly at the middle of the given three address code is a leader.
  3. Any instruction that is the target of a conditional or unconditional jump is a leader.
  4. Any instruction that immediately follows a conditional or unconditional jump is a leader.

Choose the correct answer from the options given below:






Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Dec 2022 Shift II (Paper II) PYQ

Solution

In compiler design, leaders are used to form basic blocks.

Rules for finding leaders:

  1. The first instruction of the intermediate code is always a leader.

So, statement $1$ is true.

  1. The middle instruction is not necessarily a leader.

So, statement $2$ is false.

  1. Any instruction which is the target of a conditional or unconditional jump is a leader.

So, statement $3$ is true.

  1. Any instruction immediately following a conditional or unconditional jump is also a leader.

So, statement $4$ is true.

Correct statements are:

$1,3,4$


UGC NET Computer Science PYQ

Which of the following are correct on regular expressions?

a. $\varphi + L = L + \varphi = L$
b. $\epsilon L = L\epsilon = L$
c. $\varphi L = L\varphi = \varphi$
d. $\varphi L = L\varphi = L$

Choose the correct answer from the options given below:






Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Dec 2022 Shift II (Paper II) PYQ

Solution

Statement a:

Union with empty language gives the same language.

$\varphi + L = L$

So, statement a is true.

Statement b:

Concatenation with empty string does not change the language.

$\epsilon L = L\epsilon = L$

So, statement b is true.

Statement c:

Concatenation with empty language gives empty language.

$\varphi L = L\varphi = \varphi$

So, statement c is true.

Statement d:

This says concatenation with empty language gives $L$, which is false.

So, statement d is false.

Correct statements are:

a, b and c only


UGC NET Computer Science PYQ
Match the following based on the language accepted by using brute force method of parsing.
 List-I

 List-II

a. $S \to aSa \mid aa$
I. $((2^n$ *3)-4); n > 1
b. $S \to aaSaa \mid aa$
II. $2^n$; n>=1
 
c. $S \to aaaSaaa \mid aa$
III. ((4*$2^n$)-6);n>=1

d. $S \to aaaaSaaaa \mid aa$

IV. $2^n$ - 2; n>= 2

Choose the correct answer from the options given below:






Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Dec 2022 Shift II (Paper II) PYQ

Solution

For $S \to aSa \mid aa$:

It generates strings:

$aa, aaaa, aaaaaa, \ldots$

So, length pattern is:

$2n$

Therefore,

a → II

For $S \to aaSaa \mid aa$:

It generates strings by adding two $a$'s on both sides.

So, it matches the given form IV.

Therefore,

b → IV

For $S \to aaaSaaa \mid aa$:

It generates lengths:

$2,8,14,20,\ldots$

This is:

$6n-4$

or

$((2n*3)-4)$

Therefore,

c → I

For $S \to aaaaSaaaa \mid aa$:

It generates lengths:

$2,10,18,26,\ldots$

This is:

$8n-6$

or

$((4*2n)-6)$

Therefore,

d → III

Correct matching:

a-II, b-IV, c-I, d-III


UGC NET Computer Science PYQ

Which of the following is the function of the semantic analysis phase of compilation process?






Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science June 2024 (Paper II) PYQ

Solution

Compiler phases:


Lexical analysis → Tokenization


Syntax analysis → Parsing


Semantic analysis → Type checking, type conversion, scope checking


Optimization → Loop optimization, data flow analysis


Thus type conversion belongs to semantic analysis.


UGC NET Computer Science PYQ
Which phase of compiler checks the grammar of programming?





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science June 2023 (Paper II) PYQ

Solution

Grammar of a programming language is checked during syntax analysis.

It is also called parsing.

UGC NET Computer Science PYQ
Which of the following parser is most powerful parser?





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science June 2023 (Paper II) PYQ

Solution

Canonical LR parser is more powerful than SLR, LALR and operator precedence parser.

UGC NET Computer Science PYQ
Consider $L=L_1\cap L_2$ where

$L_1=\{0^m1^m20^n1^n\mid m,n\ge 0\}$

$L_2=\{0^m1^n2^k\mid m,n,k\ge 0\}$

Then, the language $L$ is





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Nov 2020 (Paper II) PYQ

Solution

In $L_1$, after symbol $2$, we have $0^n1^n$.

But in $L_2$, after symbol $2$, no $0$ or $1$ can appear.

So, for intersection, $n=0$ in $L_1$.

Thus,

$L=\{0^m1^m2\mid m\ge0\}$

This language is context free but not regular.

UGC NET Computer Science PYQ
Which of the following statement is correct?





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science June 2023 (Paper II) PYQ

Solution

Ackermann's function is not primitive recursive.

$L = {a^n b^k c^{n+k}}$ is not regular.

$L = {a^n b^j : n = j^2}$ is not context free because it has a square relation between powers.

For context sensitive language, there exists an LBA such that $L = L(M)$, not $L \ne L(M)$.

UGC NET Computer Science PYQ
Let $L_1$ and $L_2$ be languages over $\Sigma=\{a,b\}$ represented by the regular expressions $(a^*+b)^*$ and $(a+b)^*$ respectively. Which of the following is true with respect to the two languages?





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Nov 2020 (Paper II) PYQ

Solution

$(a+b)^*$ generates all strings over $\{a,b\}$.

Now, $(a^*+b)^*$ also generates all strings over $\{a,b\}$ because $a^*$ can generate any number of $a$'s and $b$ is also available.

So,

$L_1=L_2=\{a,b\}^*$

UGC NET Computer Science PYQ
Which of the following statements is true?





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Nov 2020 (Paper II) PYQ

Solution

Context free languages are closed under union.

So, statement (a) is true.

CFLs are not closed under intersection and complement in general.

Also, every CFL is not accepted by a deterministic PDA.

Therefore, only statement (a) is true.

UGC NET Computer Science PYQ
Which of the following is not an intermediate code form?





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science Nov 2020 (Paper II) PYQ

Solution

Syntax tree, three address code and postfix notation are standard intermediate code forms.

Quadruple is mainly a representation method of three address code, not a separate intermediate code form.

UGC NET Computer Science PYQ
Consider the following language: $L = {w \in {a,b,c}^* : na(w) + nb(w) = nc(w)}$ L is





Go to Discussion

UGC NET Computer Science UGC NET PYQ UGC NET Computer Science UGC NET Computer Science June 2023 (Paper II) PYQ

Solution

The language contains strings where the number of $c$ symbols is equal to the total number of $a$ and $b$ symbols.

This counting condition can be handled by a context-free grammar, so it is context free.

But it is not linear because arbitrary balanced counting with mixed order needs more than linear grammar power.


UGC NET Computer Science


Online Test Series,
Information About Examination,
Syllabus, Notification
and More.

Click Here to
View More

UGC NET Computer Science


Online Test Series,
Information About Examination,
Syllabus, Notification
and More.

Click Here to
View More

Limited Seats
× Aspire MCA Promotion

Game Changer NIMCET Test Series 2026

Boost your preparation with mock tests, analysis and rank-focused practice.

JOIN NOW
Ask Your Question or Put Your Review.

loading...