Вы находитесь на странице: 1из 5

FACULTY OF INDUSTRIAL

SCIENCES & TECHNOLOGY


SUBJECT: DISCRETE STRUCTURE & APPLICATIONS
CODE: BCT2083 TOPIC: Chapter 5 Modeling Computation
TUTORIAL 5

DURATION: 2 weeks (week 14-15)

Week 14

1. Suppose A = {0.1}. Describe all strings belonging to A
-
.

2. Suppose a phrase-structure grammar has productions S S0, S A1, A 0. Find a
derivation of 01, 0100, and 010.

3. Suppose a phrase-structure grammar has productions S 1S0, S 0A, A 0. Find a
derivation of 00, 1000, and 110000.

4. Suppose a phrase-structure grammar has productions S S11, S 0A, S A1, A 0. Find a
derivation of 01, 0011 and 011111.

5. Let G be the phrase-structure grammar with vocabulary V = {A.B.a.b.S}, terminal element set T
= {a.b}, start symbol S, and production set P = {S ABa.S Ba.A aB.AB b.B ab}.
Which of these are derivable from ABa?

a) ba b) abb c) aba d) b e) aababa f

6. Let G be the phrase-structure grammar with vocabulary V = {A.B.a.b.S}, terminal element set T
= {a.b}, start symbol S, and production set P = {S ABa.S Ba.A aB.AB b.B ab}.
Which of these are derivable from A?

a) babaa b) aab c) bba

7. Let G be the phrase-structure grammar with vocabulary V = {A.B.a.b.S}, terminal element set T
= {a.b}, start symbol S, and production set P = {S ABa.S Ba.A aB.AB b.B ab}.
Which of these are derivable from S?

a) ba b) ab c) baab d) aababa e) aba

8. Let G be the phrase-structure grammar with vocabulary V = {A.B.0.1.S}, terminal elements T =
{0.1}, start symbol S, productions P = {S AB0.AB 1.A 0.B AB}. Which of these are
derivable from S?

a) 000 b) 11 c) 0000 d) 110 e) Both 010 and 0111

9. The productions of a phrase-structure grammar are S S1, S 0A, A 1. Find a derivation
of 0111.

10. What language is generated by the phrase-structure grammar if the productions are S S11,
S , where S is the start symbol?

11. What is the language generated by the grammar with productions S SA, S 0, A 1A, and
A 1, where S is the start symbol?


BCT2083 Tutorial 5

2

12. In the questions below let V = {S.A.B.0.1} and T = {0.1}. For each set of productions determine
whether the resulting grammar G is

(i) type 0 grammar, but not type 1,
(ii) type 1 grammar, but not type 2,
(iii) type 2 grammar, but not type 3,
(iv) type 3 grammar.

a) S A10, AB 0.
b) S B, A B, B A.
c) S AB, A 0B1, 0B1 0.
d) S 1A, A 1, S .
e) S 1AB, AB 0B, B 0, A 1B.
f) S 0B, B 1A, B 0, A 0B.

13. Let G = (V, T, S, P), where V = {a, c, A, B, S}, T = {a, c}, S is a start symbol and productions P
= {S ABc, A BB, B ac, A Bc}. If word w = acacacc belongs to the language
generated by this productions, construct the derivation tree for w. Then, write the language of
this grammar.

14. The production rules of a grammar for simple arithmetic expression are:

expression ::= digit | ( expression ) | + ( expression ) |
( expression ) | expression operator expression
digit ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
operator ::= + | | * | / |

Construct a derivation tree for arithmetic expression
( )
5 2 3 + | and
( ) 8 2/ 3 .

15. Draw the state diagram for the Finite State Machine with the following state table.










16. Construct a state table for the Finite State Machine with the following state diagram





State
f g
input input
0 1 0 1
s
0
s
0
s
1
1 0
s
1
s
2
s
2
1 0
s
2
s
2
s
0
0 1
s
3
s
1
s
2
1 1
x,1
y,0
s
0

x,1
x,0
y,1
s
2
s
1

y,0
BCT2083 Tutorial 5

3

17. Given the finite state machines with the following state table. Determine the output string if the
input strings is 01101.









18. What is the output produced by the following finite-state machine when the input string is
11101?


19. In the questions below determine the output for each input string, using this state table.

f g
input: input:
0 1 0 1
s
0
s
1
s
2
1 1
s
1
s
2
s
0
0 0
s
2
s
1
s
3
1 1
s
3
s
3
s
1
0 1

a) 1111. b) 10111. c) 000. d) 11000.


Week 15

20. Suppose that A = {1.11.01} and B = {0.10}. Find AB.

21. Suppose that A = {1.11.01} and B = {0.10}. Find BA.

22. Let A = {1.10}. Which strings belong to A
-
?

23. Let A = {0.11}. Find A
2
and A
3
.

24. Find the Kleene closure of A = {1}.

25. Find the Kleene closure of A = {00}.

26. Find the Kleene closure of A = {0.1.2}.


State
f g
input input
0 1 0 1
s
0
s
0
s
1
a b
s
1
s
2
s
2
a a
s
2
s
2
s
0
b a
BCT2083 Tutorial 5

4

27. Find the set recognized by the following deterministic finite-state machine.


28. Find all strings recognized by the following deterministic finite-state automaton.




29. Find all strings recognized by the following deterministic finite-state automaton.




30. Find the language recognized by the following nodeterministic finite-state automaton.



31. Find the language recognized by the following nodeterministic finite-state automaton.




BCT2083 Tutorial 5

5

ANSWERS CHAPTER 5: Modeling Computation

1. A
-
consists of all strings of 0s and 1s, including the empty string.

5. a and e
6. b
7. a, d, e
8. e

10. The language generated is the set of all strings consisting of an even number of 1s and
no other symbols.

11. The set of all bit strings that consist of a 0 followed by an arbitrary number of 1s.

12. a) i. b) iii. c) i. d) iv. e) ii. f) iv.

13. L(G) = { a
m
c
4
, m positive integers}

17. ababa

18. 10000.

19. The strings in A
-
are those in which each 0 is preceded by at least one 1.

20. AB = {10.110.1110.010.0110}.

21. BA = {01.011.001.101.1011.1001}.

22. a) 1110 b) 11011 c) 101 d) 11000

23. {00.011.110.1111} and {000.0011.01111.0110.1100.11011.11110.111111}.

24. {1
n
' n = 0.1.2.}.

25. {0
2n
' n = 0.1.2.}.

26. All strings of 0s, 1s, and 2s.

27. The set represented by (01)
-
.

28. All bit strings with no 1s.

29. All bit strings with an even number of 1s.

30. {0.00.10}.

31. {1.01
n
0.1
n
0 ' n > 0}.

Оценить