
Please help with #6 'rove: Given a sequence of n2 +1 distinct integers, either there is...
Please help with #6
'rove: Given a sequence of n2 +1 distinct integers, either there is an increasing subsequence of n+1 terms or a decreasing subsequence of n +1 terms.
'rove: Given a sequence of n2 +1 distinct integers, either there is an increasing subsequence of n+1 terms or a decreasing subsequence of n +1 terms.
Given an array A[1..n] representing a sequence of n integers, a subsequence is a subset of elements of A, in the same order as they appear in A. A subsequence is monotonic if it is a sequence of strictly increasing numbers. Define LMS(i) to be the length of a longest monotonically increasing subsequence of A[1..i] that must have A[i] as its last element. Write a recurrence for LMS(i) and convert into a dynamic program that calculates LMS(i) for i=1..n. This...
Give an O(n2 ) algorithm (Pseudocode) that, given a sequence S, finds the longest subsequence that first increases then decreases. For instance, in the sequence S = [10, 4, 5, 11, 2, 7, 4, 3, 9] the longest such subsequence is [4,5,11,7,4,3]. The subsequence does not have to be consecutive. (Hint: Use two arrays, one for increasing subsequences and the other for decreasing subsequences.)
Let S be a sequence of n distinct integers stored in an array as array elements S[1], S[2], · · · , S[n]. Use the technique of dynamic programming to find the length of a longest ascending subsequence of entries in S. For example, if the entries of S are 11, 17, 5, 8, 6, 4, 7, 12, 3, then one longest ascending subsequence is 5, 6, 7, 12. Specifically: (a) define a proper function and find the recurrence for...
Let's say you are given a sequence of distinct positive numbers. We want to find a subsequence with the maximum possible sum, with the restriction that we are not allowed to take three consecutive elements from the original sequence. For example, for input 1, 6, 5, 2, 7, 9, 3, 4, the subsequence with the maximum possible sum is 6, 5, 7, 9, 4 (we have two pairs of consecutive elements 6, 5 and 7, 9 but not three consecutive...
4. Consider the sequence {z,.) such that z1-0, z2-1 and æn-telths,Yn (i) Show that (n) is convergent by showing that the subsequence of odd-indexed terms is monotonic increasing and subsequence of even-indexed terms is monotonic decreasing (ii) Find the limit of {%) (Hint: Consider x,-h-i)
4. Consider the sequence {z,.) such that z1-0, z2-1 and æn-telths,Yn (i) Show that (n) is convergent by showing that the subsequence of odd-indexed terms is monotonic increasing and subsequence of even-indexed terms is monotonic...
(20 points) You are given an array A of distinct integers of size n. The sequence A[1], A[2], ..., A[n] is unimodal if for some index k between 1 and n the values increase up to position k and then decrease the reminder of the way until position n. (example 1, 4, 5, 7, 9, 10, 13, 14, 8, 6, 4, 3, 2 where the values increase until 14 and then decrease until 1). (a) Propose a recursive algorithm to...
ALGORITHM PROBLEM: A) Significant Inversions: We are given a sequence of n arbitrary but distinct real numbers <a1 , a2 ,..., an>. We define a significant inversion to be a pair i < j such that ai > 2 aj . Design and analyze an O(n log n) time algorithm to count the number of significant inversions in the given sequence. [Hint: Use divide-&-conquer. Do the “combine” step carefully] B) The Maximum-Sum Monotone Sub-Array Problem: Input: An array A[1..n] of...
Let the sequence X be defined recursively by x1 = 1 and Xn+1 = Xn + (-1)-1 for n 2 1. Then X n is a decreasing sequence. an increasing sequence. a Cauchy sequence either increasing or decreasing. QUESTION 12 Check if the following statement is true or false: COS n The sequence is divergent. True False
Given an unsorted array of distinct positive integers A [ 1......n ] in the range between 1 and 10000 and an integer i in the sane range. Here n can be arbitrary large You want to find out whether there are 2 elements of the array that add up to i. Give an algorithm that runs in time (O(n).