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...
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.
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...
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...
(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...
A sequence of n distinct values A[O..n – 1] is said to be downup if there is an index p with 0 < p < n such that the values of A decrease up to Aſp) and then increase for the remainder of the sequence. The index p of value Aſp) is the valley of the sequence. For example sequence 50, 10, 5, 2, 1, 20, 30 is downup with valley 4, since A[5] = 60 and the sequence decreases...
please prove Let - andd On -n+1 Show that a is an increasing sequence, that bn is a decreas- Let - andd On -n+1 Show that a is an increasing sequence, that bn is a decreas-
Let A = [A[1], A[2],…..,A[n]] be an array of n distinct integers. For 1 <= j <= n, the index j is a happy index if A[i] < A[j] for all 1 <= i < j. Describe an O(n)- time algorithm that finds all the happy indices in the array A. Partial credit will be given for an O(n log(n))-time algorithm and a minimal credit will be given for an O(n^2) –time algorithm. What is the running time of your...
Given the sequence an defined recursively as follows: an 3an-1+2 for n 2 1 Al Terms of a Sequence (5 marks) Calculate ai , аг, аз, а4, а5 Keep your intermediate answers as you will need them in the next question. A2 Iteration (5 marks) Using iteration, solve the recurrence relation when n21 (i.e. find an analytic formula for an). Simplify your answer as much as possible, showing your work and quoting any formula or rule that you use. In...
1. (16 pts.) Sorted Array Given a sorted array A of n (possibly negative) distinct integers, you want to find out whether there is an index i for which Al = i. Give a divide-and-conquer algorithm that runs in time O(log n). Provide only the main idea and the runtime analysis.