Question: Given a sequence, please design an algorithm that finds the longest decreasing subsequence. A subsequence ti is decreasing if for all i , ti >

Given a sequence, please design an algorithm that finds the longest decreasing subsequence. A subsequence ti is decreasing if for all i, ti > ti+1. For example, if the input sequence is 2,3,5,4,1,5,3,4,5. The longest decreasing subsequence is 5,4,3 or 5,4,1. The longest length is 3. Your algorithm only needs to give the longest length. (Bonus) If your algorithm can also output the subsequence (if there are multiple optimal solutions, print any of them), you can get some bonus points.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!