首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
CS662设计程序辅导、讲解Java,c/c++编程、Python程序辅导 辅导R语言程序|讲解数据库SQL
项目预算:
开发周期:
发布时间:
要求地区:
PRACTICE FINAL EXAM CS662
SOLUTION: Think in terms of a 4-tape Turing machine: first put all the a’s onto one tape, then all the
b’s onto the second tape, then all the c’s onto the third tape. Then just loop through all 3 tapes at
once. Reject if there is an a without a b, or a b without a c. Otherwise once we’re at the end of the
tape, accept.
3) Design a TM for strings that have the same number of a’s and b’s: Give an outline first.
SOLUTIONS:
A computation of the machine begins by finding the first a on the tape and replacing it with an X (state q1). The
tape head is then returned to position zero and a search is initiated for a corresponding b. If a b is
encountered in state q3, an X is written and the tape head is repositioned to repeat the cycle q2, q3, q4, q5. If no
matching b is found, the computation halts in state q3 rejecting the input. After all the a’s have been
processed, the entire string 4 is read in q5 and q6 is entered upon reading the trailing blank. The computation
halts in the accepting state qf if no b’s remain on the tape.
Transitions (in a tabular form, easier to read)
4) If L is a recursively enumerable (RE) language, then the strings in L can be accepted by a:
____________________.
5) If L is a recursively enumerable (RE) language, then the strings in L can be generated by an
_______________ grammar.
6) If L is RE but not recursive, then its complement cannot be RE (true or false). ____________
7) Give context-free grammars that generate the following languages.
8) Transform the grammar with productions S → abAB A → baB|λ B → BAa|A|λ into
Chomsky normal form.
Solutions:
Removing λ−productions: Here A and B are nullable variables. Then following the second step of
construction in Theorem 6.3 in the textbook, we get:
S → abAB|abA|abB|ab A → baB|ba B → BAa|A|Ba|Aa|a
Removing unit-productions(by Theorem 6.4):
S → abAB|abA|abB|ab A → baB|ba B → BAa|baB|ba|Ba|Aa|a.
There are no useless productions in the grammar. By step 1 of Theorem 6.6, we introduce variables C
and D to substitute terminals a and b.
S → CDAB|CDA|CDB|CD A → DCB|DC B → BAC|DCB|DC|BC|AC|a
C → a, D → b
By step 2 of Theorem 6.6, we introduce variables to shorten the right sides of the production.
S → EF|EA|EB|CD A → GB|DC, B → BH|GB|DC|BC|AC|a,
E → CD, F → AB G → DC H → AC C → a D → b
9) Convert the following grammar into Greibach form, then construct a corresponding NPDA:
S → aABB|aAA A → aBB|a B → bBB|A.
Solutions:
The grammar does not have any λ−productions. So we can convert it into Greibach normal form. By
applying Theorem 6.1 on last production,
S → aABB|aAA A → aBB|a B → bBB|aBB|a
By applying construction in Theorem 7.1, Define M = ({q0, q1, qf }, Σ, {S, A, B, z}, δ, q0, z, {qf}) with:
δ(q0, λ, z) = {(q1, Sz)} δ(q1, a, S) = {(q1, ABB),(q1, AA)}
δ(q1, a, A) = {(q1, BB),(q1, λ)} δ(q1, b, B) = {(q1, BB)}
δ(q1, a, B) = {(q1, BB),(q1, λ)} δ(q1, λ, z) = {(qf , z)}
10) Eliminate useless productions from
S → a|aA|B|C A → aB|λ B → Aa C → cCD D → ddd.
Solutions:
Remove those variables that do not produce any strings then remove the unreachable variables.
S → a|aA|B A → aB|λ B → Aa,
11) Construct an NPDA that accepts the following language on Σ = {a, b}, L = {w | na(w) = nb(w) + 1}.
Solutions:
M = ({q0, q1, q2}, Σ, {a, b, z}, δ, q0, z, {q2}) with
δ(q0, λ, z) = {(q1, az)} δ(q1, a, z) = {(q1, az)} δ(q1, a, a) = {(q1, aa)}
δ(q1, a, b) = {(q1, λ)} δ(q1, b, z) = {(q1, bz)} δ(q1, b, a) = {(q1, λ)}
δ(q1, b, b) = {(q1, bb)} δ(q1, λ, z) = {(q2, λ)} δ(q1, c, z) = {(q1, c)}
δ(q1, c, a) = {(qa, a)} δ(q1, c, b) = {(q1, b)}
Then M accepts L since it starts with one extra a on the stack and then uses the machine given in Example 7.4
to tell if the number of as and bs are the same. If they are and we started with one more a on the stack, then
the condition of L is met.
12) Set of all strings that are at least of length 4 and contains even number of 1’s.
Solutions:
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
代写math 1151, autumn 2024 w...
2024-11-14
代做comp4336/9336 mobile dat...
2024-11-14
代做eesa01 lab 2: weather an...
2024-11-14
代写comp1521 - 24t3 assignme...
2024-11-14
代写nbs8020 - dissertation s...
2024-11-14
代做fin b377f technical anal...
2024-11-14
代做ceic6714 mini design pro...
2024-11-14
代做introduction to computer...
2024-11-14
代做cs 353, fall 2024 introd...
2024-11-14
代做phy254 problem set #3 fa...
2024-11-14
代写n1569 financial risk man...
2024-11-14
代写csci-ua.0202 lab 3: enco...
2024-11-14
代写econ2226: chinese econom...
2024-11-14
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!