1' Let A r, p, i and B w, o, r, l, d ' What does each of the following a, b and c denote - PowerPoint PPT Presentation

About This Presentation
Title:

1' Let A r, p, i and B w, o, r, l, d ' What does each of the following a, b and c denote

Description:

1. 1. Let A ={r, p, i } and B = { w, o, r, l, d }. What does each of the following (a), (b) and (c) denote? Briefly explain in plain ... (c) S aSa | bSb | a | b ... – PowerPoint PPT presentation

Number of Views:46
Avg rating:3.0/5.0
Slides: 11
Provided by: scie210
Learn more at: http://www.cs.rpi.edu
Category:
Tags: asa | by88 | denote | each | following | strange

less

Transcript and Presenter's Notes

Title: 1' Let A r, p, i and B w, o, r, l, d ' What does each of the following a, b and c denote


1
Midterm (Models of Computation, Spring,
2001) (Key Answers)
1. Let A r, p, i and B w, o, r, l, d .
What does each of the following (a), (b) and (c)
denote? Briefly explain in plain English. (a)
AB (b) BAB (c) (r p
i)(w o r l d) (d) (w o r
l d)(r p i)(d l r o w)
Answer (a) The set of strings, including the
null string (epsilon), over the symbols (i.e.,
alphabet) r, p, i that ends with a symbol
in set w, o, r, l, d. (b) The set of strings
over the alphabet r, p, i, w, o, r, l, d that
include exactly one symbol from r, p, i.
Notice that this statement implies the set of
strings over alphabet w, o, r, l, d, including
the null string, followed by a symbol in r, p,
i followed by a string over alphabet w, o, r,
l, d, including the null string. (c) This is a
regular expression which denotes the set of
strings which start with a symbol in r, p, i
followed by a string, over the alphabet w, o, r,
l, d, including the null string. (d) This
regular expression denotes the same set of
strings expressed by BAB .
2
2. Let L1, L2, and L3 be as shown below,
where for a string x, a(x), b(x), and c(x),
respectively, mean the number of as in x, the
number of bs in x, and the number of cs in x.
L1 a, b, c L2 x x ? a,
b, c and a(x) ? b(x) L3 x x
? a, b, c and b(x) c(x) What will be
the result of each of the following set
operations? Show your answer with a set
property. (a) (L1 - L2 ) ? aibjak i, j,k ? 0
(b) (L1 - L3) ? aibjck i,j,k ?
0 (c) (L1 - L2 L3) ? aibjck
i,j,k gt 0
Answer (a) aibjak i, j, k ? 0, ik j
(b) aibjck i, j, k ? 0, j ? k
(c) aibjck i, j, k ? 0, ij ? k
3. What is the language generated by each of the
following grammars? Show your answers with a set
notation. (a) S ? 0S1 B C B ?
0B 0 C ? 1C 1 (b) S ?
AaBb Aa ? b bBb ? b Bb ? c
(c) S ? De
D ? Da E Ea ? E Ee ? ?

Answer (a) aibj i, j ? 0, i ? j
(b) b, bc (c ) ?
3
4. What is the language generated by L-system G
(a, b, c, d, h, ab), where h is defined as
follows? h(a) ac, h(b) bd, h(c)
c, h(d) d
Answer acibdi i ? 0
5. Construct a context-free grammar that
generates each of the following languages. Notice
that part (b) is the set product. (a) L1 aibj
i ? j ? 0 (b) L1aaa, bbb, ccc
(c) L3 x x ? a, b, and x xR
Answer (a) S ? aSb A A ? aA ?
(b) S ? FE F ? aFb
A A ? aA ? E ? aaa bbb
ccc Notice that with F the
grammar generates language L1. (c)
S ? aSa bSb a b ?
Notice that L3 is different from xxR x ? a,
b, which can be generated by S ? aSa bSb ?
4
6. Construct a context-free grammar which
generates the language defined by the following
syntax flow graph for ltstrangegt.
Answer Let ltstrangegt, ltheadergt, and ltbodygt
be, respectively, S, H, and B. S ? HB H
H ? H b B ? cBd cd
7. Construct a syntax flow graph which defines
the language x x ?0, 1, and the decimal
value of x is divisible by 3 . You should
briefly describe how you got your answer.
Answer We first convert the following DFA that
accepts the language (see the lecture note) to a
regular grammar, and then transform the grammar
to a syntax flow graph.
S ? 0A 1B A ? 0A 1B ? B ? 0C
1A C ? 0B 1C
To grammar
DFA
To syntax flow graph
5
8. We learned that the deterministic TM shown
below recognizes the language 0i1i i gt 0 . Is
it possible for a deterministic LBA recognizes
this language? If your answer is negative,
explain why. If your answer is positive, show a
state transition graph of your DLBA.
Change to ( , , N )
Answer Yes it is possible. Since the input is
bounded by the boundary markers and , we can
simply modify the above TM state transition graph
to a DLBA state transition graph by changing the
edge label (B, B, N) entering the accepting state
5 to ( , , N ). Notice that as in TM we assume
that the machine is reading the left- most input
symbol.
6
9. Construct a DPDA which recognizes the language
L aibjak i k gt j gt 0 .
Answer
7
10. Eliminate epsilon-transitions from the FA
shown below without changing the number of states
and the language accepted by the automaton.
  • Answer Transition analysis
  • Let x ?a? and y ?a?. Then
  • (1, x) 1, 2, 3, 4, ? (1, y) 3, 4
  • (2, x) 3, 4, ? (2, y) 3, 4
  • (3, x) ? (3, y) ?
  • ? (4, x) ?(4, y) ?

11. Let L be the language accepted by the
automaton in problem 10 above. Show an FA which
recognizes the language L.
Since L aa, b, we have L a,
b. Hence, the FA shown below can be a simple
solution for this problem .
8
12. Construct a regular expression which denotes
the language accepted by the following FA. Notice
that thick circles are accepting states.
Let r11 (abc)(ab(cb)ca) r12
ab(cb)a r22 b(cb)a r2 1
b(cb)ca Then, rS r11 r12 (r22 )r2 1
rD (r11)r12 r22 r2 1(r11)
r12 Answer r rS rD
Eliminate state C
Read off regular expression
Since the language accepted by the automaton
is a, b, c, the answer can be simply (a b
c).
13. Construct a regular grammar that produces the
same language accepted by the FA in problem 12
above.
Answer Using the state labels on the state
transition graph in problem 11 above, we get the
following. S ? aS bS cS aB ?
A ? aA B B ? bC C ?
cA aD D ? bC ?
9
14. Using the technique discussed in the class,
convert the following NFA to a DFA which accepts
the same language.
Answer
10
15. The other day, local environmentalists formed
a long human chain, everyone holding hand to
hand, to block dumping drums of chemical waste
to the river. The organizations both vice
chairwoman and vice chairman were each positioned
at each end of the chain throughout the
demonstration. A journalist who covered this
event reported that interestingly the number of
joined hands between different genders was odd
throughout the event, with no regard to the
length of the chain (i.e., the number of
activists involved). His report ended with the
following comment It was so oddly odd
that somebody should further investigate the
phenomenon. Question As a student attending the
course Models of Computation, prove that the
journalists observation is correct and natural.
Answer Let the human chain be transformed to a
sequence of nodes with all females labeled by 1
and males by 2. Then we can translate the
sequence of nodes as a problem instance of the
Sperners lemma that we studied in the class, if
we consider each pair of joined hands between
different genders as a good block. According to
the Sperners lemma the number of good blocks
(i.e., the number of joined hand-pairs) is always
odd. So the reporters observation is correct
and natural. (Refer the lecture note for the
proof of Sperners lemma by induction.)
16. Using the proof by induction technique show
that for every regular expression, we can
construct an FA which recognizes the language
that is expressed by the expression.
Answer We can simply copy the proof in the
lecture note slide numbers 88 through 89, which
is actually a proof by induction of the given
problem. (Key answer is omitted.)
Write a Comment
User Comments (0)
About PowerShow.com