Question

In: Computer Science

The syntax of the monkey languages is quite simple, yet only monkeys can speak it without...

The syntax of the monkey languages is quite simple, yet only monkeys can speak it without making mistakes. The alphabet of the language is {a, b, d, #}, where # stands or a space. The grammar is

<stop> ::= b|d

<plosive> ::= <stop>a

<syllable> ::= <plosive>|<plosive><stop>|a<plosive>|a<stop>

<word> ::= <syllable>|<syllable><word><syllable>

<sentence> ::= <word>|<sentence>#<word>

Using parse trees, which of the following speakers is the secret agent masquerading as a monkey?

Chimp: abdabaadab#ada

Baboon: dad#ad#abaadad#badadbaad

Solutions

Expert Solution

Parse tree for Chimp:

String is: abdabaadab#ada

<sentence> = <sentence> # <word>

::= <word> # <word>

::= <syllable> <word> <syllable> # <word>

::= <syllable> <word> <syllable> # <syllable>

::= <syllable> <word> <syllable> # a <plosive>

::= <syllable> <word> <syllable> # a <stop> a

::= <syllable> <word> <syllable> # a d a

::= a <stop> <word> <syllable> # a d a

::= a b <syllable> <word> <syllable> <syllable> # a d a

::= a b <plosive> <word> <syllable> <syllable> # a d a

::= a b <stop> a <word> <syllable> <syllable> # a d a

::= a b d a <word> <syllable> <syllable> # a d a

::= a b d a <word> <syllable> <plosive> <stop> # a d a

::= a b d a <word> <syllable> <stop> a <stop> # a d a

::= a b d a <word> <syllable> d a b # a d a

::= a b d a <syllable> <syllable> d a b # a d a

::= a b d a <plosive> <syllable> d a b # a d a

::= a b d a <stop> a <syllable> d a b # a d a

::= a b d a b a <syllable> d a b # a d a

We are not able to get the string that Chimp is speaking here.

Parse tree for Baboon:

String is: dad#ad#abaadad#badadbaad

<sentence> ::= <sentence> # <word>

::= <sentence> # <word> # <word>

::= <sentence> # <word> # <word> # <word>

::= <plosive> <stop> # <word> # <word> # <word>

::= <stop> a <stop> # <word> # <word> # <word>

::= d a d # <word> # <word> # <word>

::= d a d # <syllable> # <word> # <word>

::= d a d # a <plosive> # <word> # <word>

::= d a d # a <stop> # <word> # <word>

::= d a d # a d # <word> # <word>

::= d a d # a d # <syllable> <word> <syllable> # <word>

::= d a d # a d # <syllable> <word> a <stop> # <word>

::= d a d # a d # <syllable> <syllable> a d # <word>

::= d a d # a d # <syllable> a <stop> a d # <word>

::= d a d # a d # <syllable> a d a d # <word>

::= d a d # a d # a <plosive> a d a d # <word>

::= d a d # a d # a <stop> a a d a d # <word>

::= d a d # a d # a b a a d a d # <word>

::= d a d # a d # a b a a d a d # <syllable> <word> <syllable>

::= d a d # a d # a b a a d a d # <plosive> <word> <syllable>

::= d a d # a d # a b a a d a d # <stop> a <word> <syllable>

::= d a d # a d # a b a a d a d # b a <word> a <stop>

::= d a d # a d # a b a a d a d # b a <word> a d

::= d a d # a d # a b a a d a d # b a <syllable> <word> <syllable> a d

::= d a d # a d # a b a a d a d # b a <syllable> <word> <plosive> a d

::= d a d # a d # a b a a d a d # b a <syllable> <word> <stop> a a d

::= d a d # a d # a b a a d a d # b a <plosive> <stop> <word> b a a d

::= d a d # a d # a b a a d a d # b a <stop> <stop> <word> b a a d

::= d a d # a d # a b a a d a d # b a d a d b a a d


Related Solutions

C#: If the code is the only thing that you can provide without the pictures of...
C#: If the code is the only thing that you can provide without the pictures of the form, then that is fine as well. Topics: hiding/showing controls, StatusStrip, custom event arguments, radio buttons Students will create an application that uses a dialog to create a spaceship object to populate a ListView. This ListView will be able to display in either large or small icon mode using a menu option to switch between them. Selecting a spaceship in the ListView will...
Review your abilities to speak to your co-workers about theft. Is theft only stealing money? Can...
Review your abilities to speak to your co-workers about theft. Is theft only stealing money? Can it be taking other things? How will you handle the issue of theft as a medical office assistant?
How can the United States justify that we only have 5% of the world's population, yet...
How can the United States justify that we only have 5% of the world's population, yet incarcerate 25% of the world's prisoner?
There is a single-plank bridge. Only one person can cross the bridge without any stop. The...
There is a single-plank bridge. Only one person can cross the bridge without any stop. The pedestrian can cross the bridge from west to east or from east to west. If there is more than 0 pedestrian crossing the bridge from west to east, no pedestrian can try to cross the bridge from east to west, but more than 1 pedestrian can cross the bridge from west to east, and vice versa. The pedestrian can cross the bridge immediately if...
Water is an essential nutrient; you can only survive a few days without water. We live...
Water is an essential nutrient; you can only survive a few days without water. We live in a hot, humid climate and physical activity requires replacement of water loss by perspiration and vapor. Please discuss: Define dehydration Discuss how dehydration can happen with exercise. Explain the hydration schedule for physical activity. How do we prevent hyperthermia and hypothermia when we plan to exercise outside?. What is hyponatremia and how can we prevent it?
C++ Language Create Login Register program without open .txt file simple program also if you can...
C++ Language Create Login Register program without open .txt file simple program also if you can hide password input option menu 1) Login 2) Register 3) exit
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT