首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
讲解comp2022编程、辅导Python,Java,c++程序语言 讲解SPSS|辅导留学生 Statistics统计、回归、迭代
项目预算:
开发周期:
发布时间:
要求地区:
comp2022 Assignment 4 s2 2020
This assignment is due on Sunday Nov 22, 23:59 and has a coding part and a written part.
• Submit your written part (Problems 1 and 2) as a single pdf on Gradescope.
• Submit your code (Problem 3) on Ed.
• All work must be done individually without consulting anyone else’s solutions in accordance
with the University’s “Academic Dishonesty and Plagiarism” policies.
• For clarifications and more details on all aspects of this assignment (e.g., level of justification
expected, late penalties, repeated submissions, what to do if you are stuck, etc.) you are
expected to regularly monitor the Ed Forum post “Assignment Guidelines”.
Problem 1. Let Σ = {a, b} and consider the language L1 ⊆ Σ
∗ of all strings of
the form a
mu where m ≥ 0 and u has at most m many as in it. Thus, e.g., aababa
and aabba and aa are in L1, but aababaabb is not in L1.
1. Give a context-free grammar G1 = (V, Σ, R, S) that recognises the language L1.
2. Explain why your grammar is correct.
3. Explain whether or not L1 is regular.
Problem 2. In this problem you will design a context-free grammar that generates
the language associated with a non-negative integer counter. Let Σ = {p, m}. We
say that a string w ∈ Σ
∗
is a valid counter string if, when read from left to right, and
interpreting p as adding 1 and m as subtracting 1, and we start from 0, the running
sum is non-negative. For instance, ppm and pm and ppmmp are valid counter strings,
but pmmp and mpp are not valid counter string.
1. Give a context-free grammar G2 = (V, Σ, R, S) that recognises the language L2
of valid counter strings.
2. Explain why your grammar is correct.
3. Explain whether or not L2 is regular.
Problem 3. In this problem you will implement the CYK algorithm and extend
it to provide rightmost-derivations and detect ambiguous strings. Your algorithm will
have three modes: membership, rightmost-derivation, and ambiguous. Input is read
from standard input (stdin). The first line of input indicates which mode is to be
executed. The remaining input is the data to act on. Examples of usage, and of input
and output are provided in Appendix B.
1. Membership mode
• Input: membership followed by a context-free grammar in Chomsky normalform
followed by a sequence of input strings.
• Output: One line per input string, giving the string, a comma, and then 1
if the string is generated by the grammar and 0 otherwise.
1
comp2022 Assignment 4 s2 2020
2. Rightmost-derivation mode
• Input: rightmost-derivation followed by a context-free grammar in
Chomsky normal-form followed by an input string that is generated by the
context-free grammar.
• Output: A sequence of lines, each line containing the next step of a rightmost
derivation of the input string.
3. Ambiguous mode
• Input: ambiguous followed by a context-free grammar in Chomsky normalform
followed by a sequence of input strings.
• Output: One line per input string, giving the string, a comma, and then 1
if the string is ambiguous and 0 otherwise.
A Marking
Problem 1 (25 marks)
• The first part is for 10 marks. For full credit your context-free grammar should not be more
complicated than needed.
• The second part is for 5 marks. For full credit your answer should be clear, and explain why
your grammar only generates strings in L1 and why it generates all strings in L1.
• The third part is for 10 marks. An explanation of regularity requires that you provide a DFA,
NFA or RE for the language and prove it is correct. An explanation of non-regularity requires
that you provide a proof using the PHP as in lectures.
Problem 2 (25 marks)
• The first part is for 10 marks. For full credit your context-free grammar should not be more
complicated than needed.
• The second part is for 5 marks. For full credit your answer should be clear, and should explain
why your grammar only generates strings in L2 and why it generates all strings in L2.
• The third part is for 10 marks. An explanation of regularity requires that you provide a DFA,
NFA or RE for the language and prove it is correct. An explanation of non-regularity requires
that you provide a proof using the PHP as in lectures.
Problem 3 (50 marks)
• For passing the test-cases:
– 20 marks for membership mode
– 10 marks for rightmost derivation mode
– 10 marks for ambiguous mode.
You are not allowed to hard-code any of the test-cases.
• The remaining 10 marks are based on the overall quality of the code. Quality is judged based
on our answers to questions such as:
– How readable is the code? e.g. commenting, variable naming, space, line length, etc.
2
comp2022 Assignment 4 s2 2020
– Are the data structures appropriate to the problem? e.g. how the grammars are represented.
– Are the algorithms implemented in a reasonably efficient way?
– How much of the assignment was attempted.
B Input/Output formats
Input context-free grammar in Chomsky normal-form
A sequence of lines:
1. A comma separated list of variable symbols
2. A comma separated list of terminal symbols
3. The start variable
4. One or more lines of the form:
• A -> B C
• A -> a
• A -> epsilon
5. the string end
For example:
✞ ☎
A ,B ,C ,D ,S , T
a , b
T
T -> A B
T -> B A
T -> S S
T -> A C
T -> B D
T -> epsilon
S -> A B
S -> B A
S -> S S
S -> A C
S -> B D
C -> S B
D -> S A
A -> a
B -> b
end
✝ ✆
... represents the grammar:
T → AB | BA | SS | AC | BD |
S → AB | BA | SS | AC | BD
C → SB
D → SA
A → a
B → b
3
comp2022 Assignment 4 s2 2020
Membership mode
1. The input is a sequence of lines:
(a) membership
(b) A context-free grammar in Chomsky normal-form (in the format described above)
(c) Several strings to check, one on each line, followed by end
2. The output is 1 or 0 for each input string, where 1 means the string is generated by the
grammar and 0 means it is not, all followed by end.
Here is an example. If the input is:
Rightmost-derivation mode
1. The input is a sequence of lines:
(a) rightmost-derivation
(b) A context-free grammar in Chomsky normal-form (in the format described above)
(c) A single non-empty string to derive, followed by end
2. The output is a sequence of lines:
(a) Each line should be a non-empty string over the alphabet of variables and terminals
(b) The sequence of lines should represent a rightmost derivation in which each line yields
the next
(c) The last line should be end
4
comp2022 Assignment 4 s2 2020
Here is an example. If the input is:
which encodes the rightmost derivation
T ⇒ AB ⇒ Ab ⇒ ab
of the string ab.
Ambiguous mode
1. The input is a sequence of lines:
(a) ambiguous
(b) A context-free grammar in Chomsky normal-form (in the format described above)
(c) Several non-empty strings to check, one on each line, followed by end
2. The output is a sequence of lines:
(a) The output is 1 or 0 for each input string, where a 1 means the string is ambiguous, and
a 0 that it is not
Here is an example. If the input is:
because ab has one rightmost derivation, a has no rightmost derivations, and abab has two rightmost
derivations.
6
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
代做 program、代写 c++设计程...
2024-12-23
comp2012j 代写、代做 java 设...
2024-12-23
代做 data 编程、代写 python/...
2024-12-23
代做en.553.413-613 applied s...
2024-12-23
代做steady-state analvsis代做...
2024-12-23
代写photo essay of a deciduo...
2024-12-23
代写gpa analyzer调试c/c++语言
2024-12-23
代做comp 330 (fall 2024): as...
2024-12-23
代写pstat 160a fall 2024 - a...
2024-12-23
代做pstat 160a: stochastic p...
2024-12-23
代做7ssgn110 environmental d...
2024-12-23
代做compsci 4039 programming...
2024-12-23
代做lab exercise 8: dictiona...
2024-12-23
热点标签
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
软件定制开发网!