Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Example. Suppose n = 7, and the sequence of prices is 10, 1, 2, 11, 3, 4, 12. Then the longest rising trend is given

image text in transcribed

Example. Suppose n = 7, and the sequence of prices is 10, 1, 2, 11, 3, 4, 12. Then the longest rising trend is given by the prices on days 2, 3, 5, 6 and 7.

1. Give an O(n2) running time algorithm that takes a sequence of pricesP [1], P [2], . . . , P [n] and returns the length of the longest rising trend.

2. Give an O(n log n) running time algorithm that takes a sequence of pricesP [1], P [2], . . . , P [n] and returns the length of the longest rising trend.

Your friends have been studying the closing prices of tech stocks, looking for interesting patterns They've defined something called a rising trend, as follows. They have the closing price for a given stock recorded for n days in succession; let these prices be denoted P[1], P[2],... , P[n]. A rising trend in these prices is a subsequence of the prices Plij, Pli). . . . , Plik], for days ii12.. ., so that Plil

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Machine Performance Modeling Methodologies And Evaluation Strategies Lncs 257

Authors: Francesca Cesarini ,Silvio Salza

1st Edition

3540179429, 978-3540179429

More Books

Students also viewed these Databases questions

Question

What role did John Parsons play in the development of NC?

Answered: 1 week ago