in Theory of Computation
665 views
0 votes
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.
in Theory of Computation
665 views

2 Comments

@Mandeep Sing  make it answer
0
0
@deepakranjan

Such a thing would result in valid strings being accepted also. See my answer below for example
0
0

2 Answers

3 votes
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 vote
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.