Exercises on the Chomsky Normal Form and the CYK algorithm ...

134 downloads 278 Views 34KB Size Report
Exercises on the Chomsky Normal Form and the CYK algorithm. Some answers and hints. 1. Convert the following context-free grammar to Chomsky Normal ...
Exercises on the Chomsky Normal Form and the CYK algorithm Some answers and hints

1. Convert the following context-free grammar to Chomsky Normal Form: S → ab | A A → bAaA | 

S0 → Xa Xb | Xb Z1 |  S → Xa Xb | Xb Z1 Z1 → AZ2 | Xa A | a Z2 → Xa A | a A → Xb Z1 Xb → b Xa → a

2. Convert the following context-free grammar to Chomsky Normal Form: S → aSSa | AA A → AB | a |  B → b

S0 → Xa Z1 | AA | AB | a | b |  S → Xa Z1 | AA | AB | a | b A → AB | a | b Z1 → SZ2 | SXa | a Z2 → SXa | a B → b Xa → a

3. Construct CYK-tables for the strings aabb and abbb using the following grammar:

S0 → Xa Z1 | Xb S | b |  S → Xa Z1 | Xb S | b Z1 → SXb | b Xb → b Xa → a

Xb , Z1 , S, S0

Xa

Xb , Z1 , S, S0

Z1 , S, S0

S, S0

Z1 , S, S0

Xa

S, S0

Xb , Z, S, S0

Xa

Xb , Z, S, S0

Z, S, S0

Xb , Z, S, S0

Z, S, S0

Z, S, S0

S, S0

Z, S, S0

Z, S, S0

4. Construct CYK-tables for the strings abbba and aaaba using the following grammar:

2

S → AY | BZ | a | b X → AY | BZ | a | b Z → XB Y

→ XA

B → b A → a

A, X, S

B, X, S

B, X, S

A, X, S

B, X, S

Z

Z

X, S

Z

Y

Y

X, S

A, X, S

A, X, S

A, X, S

A, X, S

Y

Y

X, S

3

B, X, S

Y

Z

X, S

Z

Suggest Documents