Your goal is to present a dynamic programming algorithm that computes
Ask Expert

Be Prepared For The Toughest Questions

Practice Problems

Your goal is to present a dynamic programming algorithm that computes

Problem 2 Top earnings

You manage a hedge fund. Suppose you are given an array of numbers a1, . . . , an that summarizes a trader’s earnings (or losses) for n days. Your goal is to present a dynamic programming algorithm that computes the most lucrative trading period for this trader; i.e., your algorithm must find the pair (i, j) where i ≤ j that maximizes the sum s = ∑ j k=i ak . The algorithm should output (i, j,s) and run in Θ(n) time.

(a) Define a variable bestn in the style of DP solutions that can help solve this problem. Use sentences to explain what the variable represents.

(b) Provide an equation that defines this variable.

bestn =

(c) Provide pseudo-code for a Θ(n)-time algorithm. Prove your algorithm correct and analyze its running time. (Assume additions are O(1)-time operations.) Your pseudo-code should require < 20 lines in total and should output (i, j,s). 

Hint
ComputerAlgorithm is a set of instructions to solve a problem or even accomplishing a task. Every computerized device mainly uses algorithms, because of which the time is cut which are required to do things manually. Also, algorithmic trading is called as the automated trading or black-box trading, and uses a computer program to buy or sell the securities at a pace which is not possible for humans...

Know the process

Students succeed in their courses by connecting and communicating with
an expert until they receive help on their questions

1
img

Submit Question

Post project within your desired price and deadline.

2
img

Tutor Is Assigned

A quality expert with the ability to solve your project will be assigned.

3
img

Receive Help

Check order history for updates. An email as a notification will be sent.

img
Unable to find what you’re looking for?

Consult our trusted tutors.

Developed by Versioning Solutions.