Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The problem to solve is, in other words, to select from a sequence of n numbers a subset, including the first number, such that the

image text in transcribed

The problem to solve is, in other words, to select from a sequence of n numbers a subset, including the first number, such that the selected numbers make a longest monotonously increasing sequence. In the exercise b, build the optimal structure (with an explanation), sketch the iterative dynamic programming algorithm, and show the running-time analysis. Hints: the algorithm in the exercise a is a greedy algorithm; the answer returned in the exercise b is the length of the longest rising trend starting from P[1], so think backward beginning from P[1].

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],...,PIn]. Arising trend in these prices is a subsequence of the prices Pli1], Pli2],... ,P ik], or days i12<... i1 and plijlj for each j thus a rising trend is subsequence of the days-beginning on first day not necessarily contiguous that price strictly increases over days in this they are interested finding longest given sequence prices. example. suppose n prices then by note consist increasing but because does begin it fit definition trend. show following algorithm correctly return length giving an instance which fails to correct answer. define i-1>2 to n If PU]> Plil then Set i-j Add 1 to L Endif Endfor In your example, give the actual length of the longest rising trend, and say what the algorithm above returns. (b) Give an efficient algorithm that takes a sequence of prices PC1], P12,...,PIn] 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],...,PIn]. Arising trend in these prices is a subsequence of the prices Pli1], Pli2],... ,P ik], or days i12<... i1 and plijlj for each j thus a rising trend is subsequence of the days-beginning on first day not necessarily contiguous that price strictly increases over days in this they are interested finding longest given sequence prices. example. suppose n prices then by note consist increasing but because does begin it fit definition trend. show following algorithm correctly return length giving an instance which fails to correct answer. define i-1>2 to n If PU]> Plil then Set i-j Add 1 to L Endif Endfor In your example, give the actual length of the longest rising trend, and say what the algorithm above returns. (b) Give an efficient algorithm that takes a sequence of prices PC1], P12,...,PIn] and returns the length of the longest rising trend

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

Visual Basic6 Database Programming

Authors: John W. Fronckowiak, David J. Helda

1st Edition

0764532545, 978-0764532542

More Books

Students also viewed these Databases questions

Question

d. How were you expected to contribute to family life?

Answered: 1 week ago

Question

2. Do you find change a. invigorating? b. stressful? _______

Answered: 1 week ago

Question

10. Are you a. a leader? b. a follower? _______

Answered: 1 week ago