edited by
3,859 views
3 votes
3 votes

Given the following two grammars :

$G_{1} : S \rightarrow AB | aaB$

              $ A \rightarrow a | Aa$

              $B \rightarrow b$ 

$G_{2} : S \rightarrow a S b S | b S a S | \lambda$

Which statement is correct ?

  1. $G_{1}$ is unambiguous and $G_{2}$ is unambiguous.
  2. $G_{1}$ is unambiguous and $G_{2}$ is ambiguous. 
  3. $G_{1}$ is ambiguous and $G_{2}$ is unambiguous.
  4. $G_{1}$ is ambiguous and $G_{2}$ is ambiguous. 
edited by

1 Answer

Best answer
3 votes
3 votes

Both are ambiguous...

G1: S→AB|aaB

A→a|Aa

B→b

To generatte string "aab"

S->​AB ->AaB -> aaB -> aab  

S->aaB->aab

So ambiguous...

G2: S→aSbS|bSaS|λ

Generate" abab "

S->aSbS -> abS->abaSbS -> abab 

S->aSbS->aSb->abSaSb ->abab

So ambiguous...

selected by
Answer:

Related questions

0 votes
0 votes
1 answer
1
makhdoom ghaya asked Jul 15, 2016
2,369 views
Match the following $:$$\begin{array}{clcl} & \textbf{List – I} & & \textbf{List – II} \\ \text{a.} & \text{Chomsky Normal form} & \text{i.} & S \rightarrow b S S...
3 votes
3 votes
2 answers
4
go_editor asked Jan 6, 2017
5,435 views
Four bits are used for packed sequence numbering in a slinding window protocol used in a computer network. What is the maximum window size?481516