hw4_solution

hw4_solution - CS150 Homework 4 Due 5/24 Problem 1. (10...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
CS150 Homework 4 Due 5/24 Problem 1. (10 points) Construct a CFG for the set of all ternary strings of the form 0 i 1 j 2 k , where i + j = k . S 0 S 2 | X X 1 X 2 | ² 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Problem 2. (Exercise 5.2.1, 10 points) For the grammar and each of the strings in Exercise 5.1.2, give parse tree. Exercise 5.1.2: The following grammar generates the language of regular expression 0 * 1(0 + 1) * : S A 1 B A 0 A | ² B 0 B | 1 B | ² (a) 00101. (b) 1001. (c) 00011. (a) 00101 S A B 1 0 A B 0 1 B A 0 ² ² (b) 1001 S A B 1 B 0 B 0 B 1 ² ² (c) 00011 S A B 1 0 A B A 0 1 A 0 ² ² 2
Background image of page 2
Problem 3. (Exercise 5.4.7, 20 points) The following grammar generate prefix expressions with operands x and y and binary operators +, - , and * : E + EE | * EE | - EE | x | y (a) Find leftmost and rightmost derivations, and a derivations tree for the string +*-xyxy . (b) Prove that this grammar is unambiguous. ( Hint : show that the leftmost derivation is unique for any given input string. (a) Leftmost derivation:
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/31/2008 for the course CS 150 taught by Professor Jiang during the Spring '07 term at UC Riverside.

Page1 / 6

hw4_solution - CS150 Homework 4 Due 5/24 Problem 1. (10...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online