You are given an array A[1..n] containing numbers (not necessarily integers), wh
ID: 3837112 • Letter: Y
Question
You are given an array A[1..n] containing numbers (not necessarily integers), which can be positive or negative or zero. This problem has you construct a dynamic programming algorithm, running in O(n) time, that finds indices q and p, n greaterthanorequalto p > q greaterthanorequalto 1 such that A[q] - A[q] is maximum. Assume n greaterthanorequalto 2. (a) Let OPT(j) denote the maximum difference A[p] - A[q], where j greaterthanorequalto p greaterthanorequalto q > 1. Write a recurrence expressing OPT (j) in terms of OPT(middot) for smaller subproblems. (b) Using your recurrence explain (in pseudocode or in plain English) how one can solve the above problem in O(n) time.Explanation / Answer
Suppose towards a contradiction that for same category C the language
LC isn't empty, it doesn't contain the descriptions of all mathematician machines,
and it's decidable. Then LC¯ is additionally not empty, not containing all mathematician
machines, and decidable.
Suppose that 6 C, otherwise apply the argument below to C¯ rather than
C.
Let Min be a machine specified hMini is in LC.
We will show that the Acceptance downside is decidable, and then we'll
reach a contradiction.
Given Associate in Nursing input (hMi, w) for the Acceptance downside, we tend to constract a brand new
Turing machine Mw that will the following: on input x, Mw 1st simulates
the behaviour of M on input w and
• If M on input w loops, then thus will Mw;
• If M on input w rejects, then thus will Mw;
• If M on input w accepts, then Mw continues with a simulation of Min
on input x.
In summary:
• If M accepts w, then Mw behaves like Min, Associate in Nursingd Mw accepts an input
x if and on condition that Min will. In alternative words, L(Mw) = L(Min) C and
so hMwi LC;
• if M doesn't settle for w, then Mw doesn't settle for any input, and
L(Mw) = 6 C, which suggests hMwi 6 LC.
We have verified that (hMi, w) A if and on condition that hMwi LC, and so A
would be decidable if LC were decidable. we've got reached a contradiction.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.