Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise 8 (Multiple Choice) . Let X be inductively defined as the smallest set of finite number lists (taken from N ) satisfying the following

Exercise 8 (Multiple Choice). Let X be inductively defined as the smallest set of finite number lists (taken from N) satisfying the following closure properties:

  • Given any natural number n from N, the set X contains the one-element list [n].
  • Given any list [x1,x2,x3,...,xn] already in X, the set X also contains the list [x1,x2,x3,...,xn,y] where the additional element y is the product x1 x2 x3 xn.

Which of the following lists is NOT in X?

  1. [1,1,1,1,1]
  2. [2,4,16,256]
  3. (c) [3,3,9,81]

(d) [4,4,16,256]

Exercise 9 (Multiple Choice). Consider the grammar G (note that stands for the empty string):

  1. ::= aS | T
  2. ::= bT | U
  3. ::= cU |
  1. Which of the following strings is generated by the grammar G?
    1. aba
    2. bab
    3. (c) ca

(d) ccc

  1. Which of the following is a derivation of bbc in the grammar G?
    1. S T U bU bbU bbU bbc
    2. S bT bbT bbU bbcU bbc
    3. S T bT bbT bbU bbcU bbc
    4. S T bT bTbT bbT bbU bbcU bbc

Exercise 10 (Multiple Choice). Which of the following grammars describes the same language as 0m1n where m n?

  1. S ::= 0S1 |
  2. S ::= 0S1 | S1 |
  3. S ::= 0S1 | 0S |
  4. S ::= SS | 0 | 1 |

Exercise 11. Consider the following grammar for abstract syntax of arithmetic expressions:

E ::= E+E | EE | EE | E/E | 1 | 2 | 3 | 4

with the usual associativity and precedence for the arithmetic operators (all operators are left-associative, and / have a higher precedence than + and ).

(1) Draw an abstract syntax tree for each of the following strings:

  1. 1 2 + 3
  2. 1 2 + 3
  3. 1 2 3/4

(2) (Multiple Choice & Short Answer) Which of the following pairs of strings with different parentheses represent the same abstract syntax tree according to the above precedence and associativity? Draw that abstract syntax tree.

  1. 2 4 3 versus 2 (4 3)
  2. 1 + 2 + 3 + 4 versus 1 + (2 + (3 + 4))
  3. 2 + 3 4/2 versus 2 + ((3 4)/2)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What is an employee assistance program?

Answered: 1 week ago

Question

=+ Are they breakable for any reason?

Answered: 1 week ago

Question

=+When and under what circumstances are contracts renegotiated?

Answered: 1 week ago