CISC 223 java算法分析

CISC 223 - Assignment 2 (Winter 2024)Due: Thursday February 8, 2:00 PMRegulations on assignments• The assignments are graded according to the correctness, preciseness and legibility of the solutions. All handwritten parts, including figures, should be clear and legible. This assignment is marked out of 20 possible marks.• Please submit your solution in onQ before the due time. The submission must be in one of formats: .PDF, .JPG, .PNG, .DOCX.• Important: Assignments are evaluated based only on the files you submit in onQ. Please be careful that you submit the correct files and please verify your submission. Any additional material sent retroactively by email cannot be considered.• The assignment must be based on individual work. Copying solutions from other students is a violation of academic integrity. See the course onQ site for more information.1. (4 marks) Using the method described in Section 9.1 (and in class) convert the following regular expression into a state diagram:(ab (a + c))Here the alphabet is Σ = {a, b, c}. Note that the closure operation has highest precedence so ab* denotes strings with one occurrence of a and zero or more occurrences of b.Your answer should indicate how you arrived at the result:• As intermediate steps write down the state diagrams that you construct for subex-pressions of the given regular expression, and for each intermediate step clearly indicate which subexpression it corresponds to.• Please do not simplify/modify the state diagrams. Simplifications/modifications of the state diagrams are considered as errors when marking (independently of whether or not the state diagram remains equivalent).Please note: The question is marked based on how well you follow the steps of the algorithm of section 9.1.2. (3 marks) Using the method described in Section 9.2, convert the state diagram given in Figure 1 into an equivalent regular expression. Here Σ = {a, b, c, d}.Your answer should include the intermediate step(s) used in the construction.Figure 1: State diagram for Question 2.3. Are the following languages A and B over the alphabet Σ = {a, b, c, d} regular or nonreg-ular?• For a language that is regular, give a regular expression that defines it.• For a nonregular language, using the pumping lemma prove that it is not regular.(a) (2 marks)A = { a3ibkcmd2k | i ≥ 0, k ≥ 0, m ≥ 0}(b) (2 marks)B = { aj+5bk+3cm+1 | j ≥ 1, k ≥ 1, m ≥ 1} ∪      { brc2s+3dt+1 | r ≥ 1, s ≥ 1, t ≥ 1 }.4. (4 marks) Using the algorithm mark distinguishable pairs of states that was presented in class on week 4 and that can be found in the course notes, minimize the number of states of the DFA depicted in Figure 2.Your answer should indicate in detail how you arrived at the solution:• For each stage of the algorithm, indicate which pair(s) of states are marked as dis-tinguishable at that stage and explain the reason why.
Figure 2: The DFA to be minimized in Question 4.• Draw the minimized state diagram where each state is labeled by the corresponding names of states in the original DFA that were merged together.5. (5 marks) Let Σ = {a, b, c, d}. Give context-free grammars that generate the following languages. In each case, also give a derivation of the specified terminal string using your grammar. The derivation beginning from the start variable should indicate each individual derivation step using the notation ⇒.(a) L1 = {a2i+1b3k+1 | i ≥ k ≥ 1} Derivation for the string: a3b4.(b) L2 = {a2ib2r+1c3id2s+1 | i ≥ 0, r ≥ 0, s ≥ 0} Derivation for the string: a4bc6d3(c) L3 = {a2ib2i+1c5k+2 | i ≥ 1, k ≥ 1} Derivation for the string: a4b5c7.(d) L4 = { a3ib4kc3kd2i | i ≥ 0, k ≥ 0 } Derivation for the string a3b4c3d2(e) L5 = {a4i+1bk+3c2kd2i | i ≥ 1, k ≥ 1} ∪ {a2rbrc5sds+1 | r ≥ 1, s ≥ 1}Derivation for the string: a5b5c4d2 .
WX:codehelp

你可能感兴趣的:(后端)