ICS 6B, Homework 10 wk10(1) 4. Let G = (V, T, S, P) be the phrase

advertisement
ICS 6B, Homework 10
wk10(1)
4. Let G = (V, T, S, P) be the phrase-structure grammar with V = {0, 1, A, S}, T = {0, 1}, and set of
productions P consisting of S → 1S, S → 00A, A → 0A, and A → 0.
a) Show that 111000 belongs to the language generated by G.
b) Show that 11001 does not belong to the language generated by G.
c) What is the language generated by G?
14. Find a phrase-structure grammar for each of these languages.
a) the set consisting of the bit strings 10, 01, and 101
b) the set of bit strings that start with 00 and end with one or more 1s
c) the set of bit strings consisting of an even number of 1s followed by a final 0
16. Construct phrase-structure grammars to generate each of these sets.
a) {1n | n ≥ 0}
b) {10n | n ≥ 0}
c) {(11)n | n ≥ 0}
24. Let G be the grammar with V = {a, b, c, S}; T = {a, b, c}; starting symbol S; and productions
S → abS, S → bcS, S → bbS, S → a, and S → cb. Construct derivation trees for
a) bcbba.
b) bbbcbba.
wk10(2)
1. c) Draw the state diagrams for the finite-state machines with this state table.
2. c) Give the state table for the finite-state machine with this state diagram.
4. a) Find the output generated from the input string 10001 for the finite-state machine with the following
state diagram:
6. a) Find the output for the string 0000 when given as input to this finite-state machine:
10. Construct a finite-state machine that changes every other bit, starting with the second bit, of an input
string, and leaves the other bits unchanged.
18. Construct a finite-state machine that determines whether the input string read so far ends in at least
five consecutive 1s.
wk10(3)
2. Let T be the Turing machine defined by the five-tuples: (s0, 0, s1, 0, R), (s0, 1, s1, 0, L), (s0,B, s1, 1,
R), (s1, 0, s2, 1, R), (s1, 1, s1, 1, R), (s1,B, s2, 0, R), and (s2,B, s3, 0, R). For each of these initial
tapes, determine the final tape when T halts, assuming that T begins in initial position.
6. Construct a Turing machine with tape symbols 0, 1, and B that, when given a bit string as input, adds a
1 to the end of the bit string and does not change any of the other symbols on the tape.
10. Construct a Turing machine with tape symbols 0, 1, and B that, given a bit string as input, replaces the
first two consecutive 1s on the tape with 0s and does not change any of the other symbols on the tape.
Download