Question: A sequence of integers $A = { a _ 1 , a _ 2 , . . . , a _ n }
A sequence of integers$A a a an$is said to bebumpywhen the signs of the differences between two consecutive terms in the sequence strictly alternate between and values. A difference of zero can never be part of abumpysequence So the sequence either follows $a a a a$ $a a a a$
An example of abumpysequence is On the other hand, the sequence is notbumpybecause the differences between the three consecutive elements do not alternate. Two s also show up at the end of the sequence causing the consecutive difference to be zero.
You are given a sequence of integers$A a aan$ Your task is to find the length of the longestbumpysubsequence in A Design a dynamic programming algorithm to solve this problem.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
