###### Algorithms and Programming: Problems and Solutions

239 SOLVED PROBLEMS

Question: 14.2.4

## Assume that an LR(0)-grammar is given. Prove that each string has at most one rightmost derivation. Give an algorithm that checks whether the input string is derivable. ...

Assume that an arbitrary input string is given. We...
Question: 10.2.3

## as we said, the difficulty appears because there are several possible positions of the pattern; each position corresponds to some prefix of the pattern that is also a suffix of the input string. The finite automaton remembers only the longest one. What about others? ...

The longest prefix-suffix X determines all other p...
Question: 10.2.1

## Can the previous algorithm be used for any other string instead of abcd? ...

A problem arises when the pattern contains repetit...
Question: 12.2.4

## A leaf is added to or deleted from a balanced tree. Prove that it is possible to make the tree balanced again using several rotations and that the number of rotations does not exceed the tree height. ...

We prove the more general statement: Lemma. If a s...
Question: 14.4.7

## Find and prove the connection between the notions of LR(0)-coherence and LR(1)-coherence. ...

Assume that a grammar is fixed. The string S of te...
Question: 14.4.6

## For any LR(1)-grammar, construct an algorithm that checks if a given string is derivable in the grammar. ...

As before, at each stage of the LR-process we can ...
Question: 14.4.5

## Give the definition of the shift/reduce and shift/shift conflicts in the LR(1)-case. ...

Assume that a grammar is fixed. Let S be an arbitr...
Question: 14.4.4

## Show how to compute inductively the set State(S) of all situations coherent with a given string S. ...

(1) If a string S is coherent with a situation [K ...
Question: 14.4.3