Draw a parse tree for a sentence in this grammar which only


I. Evaluate

a) + * 5 + * 4 7 2 3
b) * + 3 + * 2 4 7 9
c) + * + * 7 2 8 6 2

II. Given the BNF rules:

::= |
::= |
::= | |
::= |
::= |
::= the | a | an
::= girl | dog | man | truck
::= big | short | hairy | red
::= sadly | quickly | slowly
::= ran | fled | sank

a) Draw a parse tree for a sentence in this grammar which only uses a terminal once.

b) Draw a second tree which uses different options for at least two nonterminals.

The differences between this parse tree and the preceding one are shown in red pencil.

III. Write a LISP function COUNT that finds the number of times x occurs in a list of integers.

(COUNT 7 ‘(7 5 9 7 3 6 7)) returns 3.

IV. Write a LISP function (DIFFERENCE X Y) that returns all the elements in Y that are not in X. (DIFFERENCE ‘(3 5 7 9) ‘(1 3 5 6 8 9)) returns (1 6 8).

Solution Preview :

Prepared by a verified Expert
Computer Engineering: Draw a parse tree for a sentence in this grammar which only
Reference No:- TGS01654907

Now Priced at $25 (50% Discount)

Recommended (95%)

Rated (4.7/5)

©TutorsGlobe All rights reserved 2022-2023.