[solved]-Need Answer Question B Give O N2 Algorithm Given Sequence S Finds Longest Subsequence Fir Q39086924
Need Answer for Question B
A. Give an O(n2) algorithm that, given a sequence S, finds thelongest subsequence that first increases then decreases. Forinstance, in the sequence S = [10, 4, 5, 11, 2, 7, 4, 3, 9] thelongest such subsequence is [4,5,11,7,4,3]. The subsequence doesnot have to be consecutive. (Hint: Use two arrays, one forincreasing subsequences and the other for decreasingsubsequences.)
B. Consider the modification of (A) which requires that you findthe longest subsequence that first increases, then decreases, anddoes not repeat any values.
For instance, given the input sequence, 10,4,5,11,2,7,4,3,9 thesubsequence 4,5,11,7,4,3 would be disallowed because the value 4 isrepeated. The longest valid subsequence would 4,5,11,7,3. Explainwhy the kind of dynamic programming technique used in (A) cannot beadapted to solve this problem.
Expert Answer
Answer to Need Answer for Question B A. Give an O(n2) algorithm that, given a sequence S, finds the longest subsequence that first… . . .
OR

