CSC2047代做、代写Java,c/c++语言、代做Python程序设计代做SPSS|代写Web开发

CSC2047/Assignment 2 (v1)1. Decide whether each of the following expressions are true or not. Answer yes or no.Hint: Remember that e.g. 4n = O(n2) is true, even though 4n = O(n) is also the case.In any case where it is not true, perform an asymptotic analysis using the informal methoddiscussed in the lecture so as to provide a correct O-complexity (that is, do not provide an Ocomplexitywhich is unnecessarily high; e.g. for 4n, O(n) would be fine, however O(n2) would not).2. Consider the languageL = {hG, ni | G is an undirected graph with n connected components}.Consider the following undirected graphs:(a) For each of the following statements, decide whether it holds.(i) hG1, 1i ∈ L [1 mark](ii) hG2, 2i ∈ L [1 mark](iii) hG3, 1i ∈ L [1 mark](iv) hG3, 4i ∈ L [1 mark](v) hG4, 3i ∈ L [1 mark](vi) hG4, 4i ∈ L [1 mark](b) Prove that L is decidable by providing a high-level decider. (That is, an algorithm-likedescription in English, cf. the according lecture slides) Your implementation should requireno more than polynomial time. [2 marks](c) Argue that your decider runs in polynomial time. Do so by reasoning about the runtime ofits individual steps, the number of steps required, etc. as in the lecture. [2 marks]Page 3 of 9CSC2047/Assignment 2 (v1)3. Consider the following Turing machine M with input alphabet Σ = {0, 1, #}:(a) Let C1 be the initial configuration for the input word #101 and let C2 be the configurationyielded by C2. That is, C2 is the configuration obtained from the Turing machine after onestep when it is started on the word #101.(i) Provide C1 in terms of a string [1 mark](ii) Provide C2 in terms of a string [1 mark](b) Decide whether each of the following strings would be accepted by the Turing machine.Write down the computation the Turing machine performs for each of them in terms of asequence of configurations. For the accepted ones, answer yes; otherwise, no.(i) # [1 mark](ii) ## [1 mark](iii) 0 [1 mark](iv) #0 [1 mark](v) #1 [1 mark](vi) #00 [1 mark](vii) #01 [1 mark](viii) #10 [1 mark](ix) #11 [1 mark](x) #101 [1 mark](c) What is the language of accepted (input) words of this Turing machine? Describe thelanguage using a regular expression. [1 mark](d) What is the language of (output) words which may be on the tape at the moment theTuring machine has moved to the accepting state? Describe the language using a regularexpression. [1 mark](e) What is the worst-case runtime f(n) of this Turing machine for a word of length n? [2 marks](f) What is the best-case runtime g(n) of this Turing machine for a word of length n? [2 marks](g) Formalise the graphical representation of the Turing machine above as a 7-tuple. [2 marks]Page 4 of 9CSC2047/Assignment 2 (v1)4. Consider the following three-tape Turing machine with input alphabet Σ = {a, b, c}:a, ␣, ␣→(a, N),(a, R),(a, R) a, ␣, ␣ → (a, N),(a, R),(a, R)a, ␣, ␣ → (a, R),(a, R),(␣, N)b, ␣, ␣ → (b, N),(␣, N),(␣, N)b, a, ␣ → (b, R),(␣, N),(␣, N)b, ␣, ␣ → (b, N),(␣, L),(␣, N)c, ␣, ␣ → (c, N),(␣, N),(␣, N)c, ␣, a → (c, R),(␣, N),(␣, N)c, ␣, ␣ → (c, N),(␣, N),(␣, L)␣, ␣, ␣→ (␣, N),(␣, L),(␣, L) ␣, ␣, ␣→ (␣, N),(␣, L),(␣, L)␣, ␣, ␣→ (␣, N),(␣, N),(␣, N)(a) Decide whether each of the following strings would be accepted by the Turing machine.Write down the computation the Turing machine performs for each of them in terms of asequence of configurations. For the accepted ones, answer yes; otherwise, no.(i) ε [1 mark](ii) abc [1 mark](iii) abbbcc [1 mark](iv) abbb [1 mark](v) bac [1 mark](vi) aabbbbbbcccc [1 mark](b) Which language does this machine recognise? Provide the language in set notation.[2 marks](c) Provide a two-tape Turing machine which recognises the same language and still runs inthe same runtime order O(n). [2 marks]Page 5 of 9CSC2047/Assignment 2 (v1)5. Consider the following nondeterministic Turing machine with input alphabet Σ = {0, 1}:(a) Decide whether each of the following strings would be accepted by the Turing machine.Write down a computation the Turing machine performs for each of them in terms of asequence of configurations. For the accepted ones, the computation you write down shouldbe an accepting computation. For the accepted ones, answer yes; otherwise, no.(i) ε [1 mark](ii) 0 [1 mark](iii) 1 [1 mark](iv) 01 [1 mark](v) 10 [1 mark](vi) 101 [1 mark](vii) 11100 [1 mark](viii) 10100 [1 mark](b) What is the language of accepted words of this Turing machine? Describe the languageusing a regular expression. [2 marks](c) What is the worst-case runtime f(n) of this Turing machine for a word of length n? Rememberthat you have to consider the maximum over all possible runs for the word. [2 marks](d) What is the best-case runtime g(n) of this Turing machine for a word of length n? Rememberthat you have to consider the maximum (not the minimum) over all possible runsfor the word. [2 marks](e) What is the maximum number ofCSC2047作业代做、代写Java,c/c++语言作业、代做Python程序设计作业 代做SPSS|代写Web开发 different runs for a given word of length n? [1 mark](f) What is the minimum number of different runs for a given word of length n > 0? [1 mark](g) Provide a (deterministic) Turing machine which always halts which recognises the samelanguage as this nondeterministic Turing machine. [2 marks](h) Formalise the graphical representation of the nondeterministic Turing machine above as a7-tuple. [2 marks]Page 6 of 9CSC2047/Assignment 2 (v1)6. Consider the languageHAMPATH = {hG, s, ti | G is a directed graph with a Hamiltonian path from s to t}HAMPATH can be reduced to SAT as follows: Consider an arbitrary directed graph G = (V, E)with n vertices and m edges. We assume V = {v1, . . . , vn}. We consider the set of variablesC = {ci,j | 1 ≤ i ≤ n and 1 ≤ j ≤ n}.Consider formula φ consisting of the conjunction (∧) of the following set S of clauses:S = Satleastonce ∪ Smaxoneperstage ∪ Snottwice ∪ Sfirst ∪ Slast ∪ Spathwhere• Satleastonce = {(ci,1 ∨ . . . ∨ ci,n) | 1 ≤ i ≤ n},• Smaxoneperstage = {ci,k ∨ cj,k | 1 ≤ i ≤ n and 1 ≤ j ≤ n and i • Snottwice = {(ck,i ∨ ck,j ) | 1 ≤ k ≤ n and 1 ≤ i ≤ n and 1 ≤ j ≤ n and i • Sfirst = {ci,1} where vi = s,• Slast = {ci,n} where vi = t,• Spath = {ci,k ∨ cj,k+1 | (vi, vj ) ∈/ E and 1 ≤ i ≤ n and 1 ≤ j ≤ n and 1 ≤ k ≤n − 1 and i 6= j}.For instance, if we consider the set A = {a ∨ b, c, c ∨ a}, then the conjunction of the clauses ofA would be φ = (a ∨ b) ∧ c ∧ (c ∨ a), where the order of clauses in φ is arbitrary. The way theencoding works is similar to how the nondeterministic decider N1 from “Time Complexity - Part3” recognises HAMPATH . A variable ci,k encodes the fact that that node viis chosen as thek-th number (pk in the algorithm). Satleastonce ensures that each node is chosen at least once.Accordingly, Snottwice ensures that each node is chosen no more than once: if vk it is chosen asthe i-th number, then it cannot be chosen again as later number j. Sfirst and Slast ensure thats and t are the first and last nodes of the path to be obtained. Spath encodes step 4. of thealgorithm seen in the lecture: it disallows that a node viis followed by node vjif there is no edgefrom the first to the second node.(a) Consider the following directed graphs:Encode the following problems into Boolean formulas as described above.(i) hG1, v1, v2i ∈ HAMPATH [1 mark](ii) hG2, v1, v3i ∈ HAMPATH [1 mark](iii) hG3, v1, v4i ∈ HAMPATH [1 mark](iv) hG4, v1, v4i ∈ HAMPATH [1 mark]wwwwwwwwwwwww(continued at next page)Page 7 of 9CSC2047/Assignment 2 (v1)wwwwwwwwwwwww(continued from previous page)(b) DIMACS is a text-based format for Boolean formulas in CNF. Read the description athttp://people.sc.fsu.edu/~jburkardt/data/cnf/cnf.html. Encode the followingproblems in DIMACS. Also state which ci,j is assigned which variable number. Afterwards,use the webpage https://jgalenson.github.io/research.js/demos/minisat.htmlto solve these SAT problems automatically. For each problem, provide the resulting output.If the problem is satisfiable, provide the Hamilton path which corresponds to the solution.(i) hG1, v1, v2i ∈ HAMPATH [1 mark](ii) hG2, v1, v3i ∈ HAMPATH [1 mark](iii) hG3, v1, v4i ∈ HAMPATH [1 mark](iv) hG4, v1, v4i ∈ HAMPATH [1 mark](c) SAT problems can be solved in O(2q· p) where q is the number of variables and p thelength of the formula (total number of literals). Let EXPTIME =Sk TIME(2nk) bethe set of languages which are decidable in exponential time.(i) Provide the complexity of deciding HAMPATH via SAT using the O-notation dependingon the number of vertices n. [2 marks](ii) Is HAMPATH in EXPTIME? Justify your answer. [2 marks](iii) Is this method to solve HAMPATH faster than the one from the lecture? Justify youranswer. [2 marks](d) Describe an encoding of the following language to SAT:ANYHAM = {hGi | G is a directed graph with a Hamiltonian path}[2 marks](e) Describe an encoding of the following language to SAT:HCIRC = {hGi | G = (V, E) is a directed graph and it has a Hamiltonian pathfrom some s ∈ V to some t ∈ V with (t, s) ∈ E} [2 marks](f) Describe how you could exclude a particular Hamiltonian path when constructing the SATproblem (e.g. because you have already found it and you want to find another one).[2 marks]Page 8 of 9CSC2047/Assignment 2 (v1)7. Consider the recurrences below defined for n ≥ 0.Note: The lecture discussing the methods necessary for solving this exercise is scheduled forThursday, February 27th, 2020.f(n) = (1 if n = 0f(n − 1) + 2n elseg(n) = (1 if n = 02g(n − 1) + 2n else(a) Give the values for the following items.(i) f(0) [1 mark](ii) g(1) [1 mark](iii) g(2) [1 mark](iv) f(10) [1 mark](b) Give a closed-form solution to the recurrence for f(n) and show your process for arrivingat this solution. [2 marks](c) Prove the correctness of your solution in (b) by induction. [2 marks](d) Prove that g(n) = 5 · 2n − 2n − 4 by induction. [2 marks]Page 9 of 9转自:http://www.6daixie.com/contents/3/5007.html

你可能感兴趣的:(CSC2047代做、代写Java,c/c++语言、代做Python程序设计代做SPSS|代写Web开发)