• retagged by
40,754 views
83 83 votes

Consider the following statements about the context free grammar

$$G = \left \{ S \rightarrow SS, S \rightarrow ab, S \rightarrow ba, S \rightarrow \epsilon \right \} $$

  1. $G$ is ambiguous
  2. $G$ produces all strings with equal number of $a$’s and $b$’s
  3. $G$ can be accepted by a deterministic PDA.

Which combination below expresses all the true statements about $G$?

  1. I only
  2. I and III only
  3. II and III only
  4. I, II and III

7 Answers

Best answer
161 161 votes
  1. True. $G$ is ambiguous. E.g. the string $ab$ has multiple derivation trees like $S \rightarrow SS \rightarrow abS \rightarrow ab$, and $S \rightarrow ab$.
     
  2. False. $G$ does not produce all strings with equal no. of $a$`s and $b$`s. ($aabb$ cannot be generated).
     
  3. True. The given grammar $G$ generates the language $(ab+ba)^*$, which is Regular and therefore also DCFL. So, a D-PDA can be designed for $G$.
     

Hence, the answer is option B.

• edited by
5 5 votes

Is ambiguous, as it has two parse tree for the string “abbaba”

G doesn’t product all strings of equal number of a’s and b’s, for ex: string “aabb” doesn’t generate by grammar G.
The language generated by G can be accepted by DPDA. We can notice that grammar G generates, a’s and b’s in pair, i.e. either “ab” or “ba”, so the strings in language are {ab, ba, abab, abba, baba, ….}
We can design the DPDA:

 

4 4 votes

II is definitely false. aabb not generated.


I is true.

$S\rightarrow SS$

$S\rightarrow \epsilon S$

$S\rightarrow \epsilon ba$

$S\rightarrow ba$

--and--

$S\rightarrow SS$

$S\rightarrow S\epsilon$

$S\rightarrow  ba\epsilon$

$S\rightarrow ba$


III is correct.

Even though this grammar is ambiguous, we can translate it into an unambiguous version, and DPDA can accept it.

Being ambiguous is the property of a grammar, not a language.

DPDA can't accept inherently ambiguous languages. (ie the Languages for which there's no unambiguous grammar)

This language is fine.

 

Option B

1 1 vote

The confusion here is for point 2.

"since grammer itself is ambigious , then option has full right to be ambigious😂"
jokes apart.

 G produces all strings with equal number of a’s and b’s.

this means that can G produce Every possible stirings where we have equal a and b . so Obviously false"aabb".
Had it been like this.

"all strings produced by G has equal a and b " then it'll be correct .

For more clearity , reffer to this comment 
 

 

Answer:
Position:
Show:

Related questions

67 67 votes
6 answers 6 answers
37.2k
37.2k views
Rucha Shelke asked Sep 26, 2014
37,157 views
A CPU generates $32$-bit virtual addresses. The page size is $4$ KB. The processor has a translation look-aside buffer (TLB) which can hold a total of $128$ page table en...
77 77 votes
10 answers 10 answers
44.9k
44.9k views
Rucha Shelke asked Sep 26, 2014
44,869 views
Consider the following recurrence:$ T(n)=2T\left ( \sqrt{n}\right )+1,$ $T(1)=1$Which one of the following is true?$ T(n)=\Theta (\log\log n)$$ T(n)=\Theta (\log n)$$ T(n...
37 37 votes
5 answers 5 answers
13.2k
13.2k views
go_editor asked Nov 7, 2016
13,171 views
The grammar$S\rightarrow AC\mid CB$$C\rightarrow aCb\mid \epsilon$$A\rightarrow aA\mid a$$B\rightarrow Bb\mid b$generates the language $ L=\left \{ a^{i}b^{j}\mid i\neq j...
53 53 votes
4 answers 4 answers
18.4k
18.4k views
Rucha Shelke asked Sep 26, 2014
18,373 views
Which one of the following grammars generates the language $ L=\left \{ a^{i}b^{j}\mid i\neq j \right \}$?$S\rightarrow AC\mid CB$$C\rightarrow aCb\mid a\mid b$$A\rightar...