Home / Expert Answers / Computer Science / problem-2-rising-trends-25-marks-given-an-array-p-1-n-where-p-i-represents-t-pa468

(Solved): Problem 2: Rising Trends (25 marks) Given an array \( P[1 . . n] \) where \( P_{i} \) represents t ...



Problem 2: Rising Trends (25 marks)
Given an array \( P[1 . . n] \) where \( P_{i} \) represents the price of a stock on day

Problem 2: Rising Trends (25 marks) Given an array \( P[1 . . n] \) where \( P_{i} \) represents the price of a stock on day \( i \), find the length of the longest rising trend. A rising trend is a subsequence of days, beginning on day 1 and not necessarily contiguous, where the price of the stock strictly increases. 1. (7 marks) Given \( P \), define a recurrence relation for \( L_{j} \) which denotes the longest rising trend that begins on day \( j \). 2. Using this recurrence, implement and test a dynamic programming algorithm that: (a) (10 marks) Finds the longest rising trend. (b) (5 marks) Describes the optimal solution. 3. (3 marks) State the order of complexity of your algorithm.


We have an Answer from Expert

View Expert Answer

Expert Answer


Hence is your answer =====================?=========== 1) Given Array p [ l,n] where P_{i} represents the price of Lj , Relation denotes the longest.
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe