Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

Algorithms [Sedgewick, Robert]

.pdf
Скачиваний:
143
Добавлен:
02.05.2014
Размер:
4.8 Mб
Скачать

268

Exercises

1.Give a regular expression for recognizing all occurrences of four or fewer consecutive l’s in a binary string.

2.Draw the nondeterministic pattern matching machine for the pattern description (A+B)* +C.

3.Give the state transitions your machine from the previous exercise would make to recognize ABBAC.

4.Explain how you would modify the nondeterministic machine to handle the “not” function.

5.Explain how you would modify the nondeterministic machine to handle “don’t-care” characters.

6.What would happen if match were to try to simulate the following machine?

7.Modify match to handle regular expressions with the “not” function and “don’t-care” characters.

8.Show how to construct a pattern description of length M and a text string of length N for which the running time of match is as large as possible.

9.Why must the deque in match have only one “scan” sentinel in it?

10.Show the contents of the deque each time a state is removed when match is used to simulate the example machine in the text with the text string ACD.

Соседние файлы в предмете Алгоритмы