• retagged by
12,612 views
53 53 votes

$A$ CFG $G$ is given with the following productions where $S$ is the start symbol, $A$ is a non-terminal and a and b are terminals.

  • $S → aS \mid A$
  • $A → aAb \mid bAa \mid \epsilon$

For the string "$aabbaab$" how many steps are required to derive the string and how many parse trees are there?

  1. $6$ and $1$
  2. $6$ and $2$
  3. $7$ and $2$
  4. $4$ and $2$

2 Answers

Best answer
63 63 votes
$S\underset{1}{ \rightarrow} aS$
$\quad \underset{2}{\rightarrow} aA$
$ \quad \underset{3}{\rightarrow} aaAb$
$\quad \underset{4}{ \rightarrow} aabAab$
$\quad \underset{5}{ \rightarrow} aabbAaab$
$\quad \underset{6}{ \rightarrow} aabbaab$

Thus $6$ steps are needed and only one way to derive the string so only one parse tree.

Correct Answer: $A$
• edited by
Answer:
Position:
Show:

Related questions

47 47 votes
7 answers 7 answers
13.8k
13.8k views
Ishrat Jahan asked Oct 29, 2014
13,779 views
A CFG $G$ is given with the following productions where $S$ is the start symbol, $A$ is a non-terminal and $a$ and $b$ are terminals.$S \to aS \mid A$$A \to aAb \mid bAa ...
100 100 votes
7 answers 7 answers
30.9k
30.9k views
Ishrat Jahan asked Oct 29, 2014
30,904 views
Host $X$ has $IP$ address $192.168.1.97$ and is connected through two routers $R1$ and $R2$ to an­other host $Y$ with $IP$ address $192.168.1.80$. Router $R1$ has $IP$ ad...
76 76 votes
10 answers 10 answers
22.6k
22.6k views
Ishrat Jahan asked Oct 29, 2014
22,626 views
Host $X$ has IP address $192.168.1.97$ and is connected through two routers $R1$ and $R2$ to an­other host $Y$ with IP address $192.168.1.80$. Router $R1$ has IP addresse...
23 23 votes
3 answers 3 answers
12.8k
12.8k views
Ishrat Jahan asked Oct 29, 2014
12,790 views
Consider the code fragment written in C below : void f (int n) { if (n <= 1) { printf ("%d", n); } else { f (n/2); printf ("%d", n%2); } }Which of the following im...