21F-COMSCI131-1 Midterm
ANPING TAO
TOTAL POINTS
38.5 / 101
Copyright By PowCoder代写 加微信 powcoder
QUESTION 1
lxor in OCaml 7 pts
1.1 lxor type 1 / 1 ✓ – 0 pts Correct
– 1 pts Incorrect
– 0.5 pts Partially correct
1.2 lxor implementation 1 / 6 – 0 pts Correct
✓ – 3 pts Incorrect recursive step ✓ – 2 pts Incorrect base case
– 1 pts Missing rec
– 6 pts No answer
– 2 pts Partially correct – 6 pts Incorrect
Consider p as a list in Ocaml, you should write a recursive function checksum.
Base case : [] -> 0
Recursive case: head::tail -> head lxor (checksum tail)
QUESTION 2
Shell syntax 40 pts
2.1 Shortest possible sequence 2 / 2 ✓ – 0 pts Correct
– 2 pts Incorrect
– 1 pts Partially correct
2.2 All terminal sequence 6 / 6 ✓ – 0 pts Correct
– 3 pts Partially correct – 6 pts No answer
– 2 pts Partially correct
– 4 pts Incorrect but on right path – 6 pts Incorrect
2.3 Ambiguity 2 / 10 – 0 pts Correct
✓ – 8 pts Incorrect or missing example of ambig_sh_grammar
– 2 pts Incorrect or missing answer of 1st part of question
– 6 pts ambig_sh_grammar doesn’t specify same langauge as sh_grammar
– 10 pts Incorrect or no answer
– 6 pts Missing or incorrect illustration of ambiguity
Please modify the sh_grammar to generate an ambiguous version instead of creating your own.
2.4 Syntax diagram 0 / 12 – 0 pts Correct
✓ – 12 pts no submission
– 6 pts Did not combine in one big syntax diagram
and replace the nonterminals
– 1 pts Mistake on Program
– 1 pts Mistake on CompleteCommands
– 1 pts Mistake on List
– 1 pts Mistake on AndOr
– 1 pts Mistake on Pipeline
– 1 pts Mistake on Pipesequence
– 1 pts Mistake on Linebreak
– 1 pts Mistake on NewlineList
– 1 pts Mistake on CompleteCommand
– 1 pts Mistake on SeparatorOp
– 4 pts Did not use loops, backtrack etc. to simplify
and minimize nonterminals enough. Also, a diagram should not call itself in to minimize nonterminals.
– 3 pts To minimize nonterminals, a diagram should not call itself.
– 3 pts Needs some more simplification
– 1 pts Some things could have been simplified more.
– 5 pts Not really in the syntax of Webber – 12 pts Wrong
– 1 pts Some mistakes, point ajustment
2.5 Recursive loop? 7 / 10 + 0 pts No Answer
Conclusion
+ 3 pts Correct
✓ + 2 pts Partial credit + 0 pts Incorrect
✓ + 4 pts Correct
+ 3 pts Partial credit (3pt) + 2 pts Partial credit (2pt) + 0 pts None provided
+ 3 pts Correct
+ 2 pts Partial credit (2pt): example given but
✓ + 1 pts Partial credit (1pt): No concrete example + 0 pts None given / Incorrect
QUESTION 3
3 High level synchronization primitive 0 / 12 – 0 pts Correct
– 3 pts No mentioning that the libraries need to be correct / using primitives correctly
– 3 pts Mentioning Java Memory Model but somewhat incorrect reasoning or no reasoning that protecting the boundaries through the primitives is enough to be safe.
– 6 pts No or wrong justification by appealing to Java Memory Model (boundaries)
– 6 pts No or wrong mentioning of conditions that make the assumption valid
✓ – 12 pts No submission
– 1 pts Either too convoluted to understand or too
simplistic/no real explanation
– 1 pts Mostly everything seems to be correct but I
don’t seem to understand the reasoning behind the insufficiency behind BoundedQueue/Exchanger in specific cases.
– 12 pts Generic definitions without specifically applying it to the problem
– 12 pts The problem is not asking about tradeoffs between primitives and the higher classes
QUESTION 4
4 All synchronized methods 5 / 7
✓ + 2 pts Pro: Discussion on race condition
+ 1 pts Pro: Discussion on race condition (partially correct)
+ 0.5 pts Pro: Other valid but secondary issues
+ 2 pts Con: Discussion on race condition or deadlock
✓ + 3 pts Con: Discussion on Performance
+ 1.5 pts Con: Discussion on Performance (Partially correct, insufficient explanation, etc.)
+ 1 pts Con: optimisation
+ 0.5 pts Con: Other valid but secondary issues + 0 pts No/Wrong answer
QUESTION 5
OCaml diagnostics 16 pts
5.1 Recursive function 1 / 4 – 0 pts Proper error analysis
✓ – 1 pts Unclear or incomplete explanation of error – 2 pts No/wrong explanation of error
– 0 pts Proper extension and downside analysis
– 1 pts Viable extension but incomplete downside
analysis or unclear explanation
✓ – 2 pts Missing or improper extension & downside
5.2 Recursive typing 1 / 6 – 0 pts Proper diagnostic
✓ – 1 pts Unclear or partially-correct explanation of
– 2 pts No/Wrong Diagnostic
– 0 pts Correct extension and downside explanation – 1 pts Extension overall good but some part’s
– 2 pts Downside analysis is incorrect/Missing – 3 pts Extension is improper, but the potential
downside is OK
✓ – 4 pts No/Wrong extension and downside
5.3 Tuple vs. list 3 / 6
✓ – 0 pts Proper error diagnostic
– 1 pts Unclear/Incomplete error explanation
– 2 pts No or wrong dianostic
– 0 pts Valid extension and downside analysis – 1 pts Extension overall good, unclear ext or
– 2 pts No/Wrong downside analysis
✓ – 3 pts Extension is not proper but with some good analysis
– 4 pts No extension
QUESTION 6
6 Namespace 4 / 5
+ 0 pts No valid namespace and correct pairs + 0.5 pts Get 1-2 valid namespaces but (mostly)
incorrect pairs; or any # namespace but no valid pair + 2 pts Get 1-2 valid namespaces and (mostly)
correct pairs
+ 2.5 pts 3-4 valid namespaces but some incorrect
+ 3 pts 3-4 valid namespaces and (mostly) correct
+ 3.5 pts 5-6 valid namespaces but some incorrect
✓ + 4 pts 5-6 valid namespaces and (mostly) correct pairs
+ 4.5 pts $$>$$6 valid namespaces but some incorrect pairs
+ 5 pts $$>$$6 valid namespaces and (mostly) correct pairs
QUESTION 7
7 Pattern matching in Java 17 & OCaml 5.5 / 14
+ 0 pts No Answer / Irrelevant ✓ + 4 pts Partial credit: 4
+ 8 pts Partial credit: 8 + 11 pts Partial credit: 11 + 14 pts Full credit: 14
✓ + 1.5 pts + Adjustment 1 P1: Superficial
3 Irrelevant
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com