1,019 views
0 0 votes
Language L = {a^n b^n w | n ≥ 0, w ∈ {c, d}*, |w| = n} is
(a) Regular (b) DCFL
(c) NCFL (d) Not context-free
Solution: Option (d)
Explanation:
Not possible to check for w as stack will be empty after checking for a and b

 

My Opinion: we can insert 2n no of a in stack and after finding of b , pop one b . In this way after a and b operation , stack will have n no of b . Now since w ∈ {c, d}*, |w| = n , we can pop up b on every alphabet of w. So language should be DCFL.

 

Correct me if my understanding is wrong.

2 Answers

3 3 votes

For a given language

$a^{n}b^{n}w | n \geqslant 0, w\epsilon \left \{ c,d \right \}^{*}$

We can't have Push Down Automata. This is because, we cannot maintain (push to stack) count for $a$'s and decrement (pop from stack) count when we see $b$'s in input. Since the stack would be empty after seeing last $b$ of $b^{n}$, so $w$ cannot be checked for validity (i.e has $n$ length).

Your opinion of

  • pushing $2$ $a$'s for every $a$ you see on input
  • and popping single $a$ for every $b$ you see in $b^{n}$
  • and popping single $a$ for each character you see on $w$

would not work for few cases.

For example:

Consider a string

$aaabbccdd$

On seeing $a$, I will put two $a$'s on stack. So when I have read $aaa$, stack will look like below

On seeing $b$, I will pop single $a$ from stack. So when I have read $aaabbb$, stack would look as below 

Now, on seeing every character of $w$, I will pop single $a$. So after I have read complete input $aaabbccdd$, stack would be empty.

But the string $aaabbccdd$ is not a valid string in the language. Number of $a$'s are not equal to number of $b$'s

1 1 vote
Your approach will work in all cases of

|b| + |w| = 2n as you are popping each a on every b and every character of w.

but we have to check two individual conditions that a^n and b^n and |w| = n. And all this can't be done with a single stack. So it's not CFL.
Position:
Show:

Related questions

0 0 votes
0 0 answers
150
150 views
lambodar_pal asked Jul 27
150 views
The intersection of a context free language and a regular languagea)need not be regularb)need not be context freec) is always regulard) is always context free  
1 1 vote
0 0 answers
430
430 views
dazeeee asked Apr 3, 2024
430 views
Give a context-free grammar for each of the following languages. Consider, Σ={0,1}.A. The language of strings that start with 1B. The language of strings of the form WWR ...
1 1 vote
1 1 answer
732
732 views
practicalmetal asked Mar 20, 2023
732 views
The complement of the languages:i) {ww | w in (0+1)*}ii) {$a^n b^nc^n$ | n>1} area) Context Free b) Not Context Free c)are DCFL’s d)None