Question: In this JAVA project, you will help to implement this critical piece of code, i.e., to quickly identify purchasing and selling points to maximize the
In this JAVA project, you will help to implement this critical piece of code, i.e., to quickly identify purchasing and selling points to maximize the profit in a given time frame. Your program (TradeStock) should run in command line. It takes two arguments: name of a binary file that contains stock prices in chronological order and the algorithm being used. It prints out your name, name of the input file, name of the algorithm, the optimal purchasing time, the optimal selling time, and the estimated profit. Each input file consists of the following in binary format: n, the length of the stock price series. It has type int (4 bytes in big-endian). n stock prices. Each price has type oat (4 bytes in big-endian).
For example, the input file mystock0.bin contains 10 prices in chronological order: 10 92.4224 34.3862 59.6091 34.2989 36.5064 54.0163 21.1790 64.0800 16.7446 34.2500
The following command finds the optimal purchasing and selling point for mystock0.bin: java -jar TradeStock.jar mystock0.bin 2 and returns the following: Yixin Chen mystock0.bin Theta(n) Divide and Conquer 6, 7, 42.9010
Note that the series of stock prices uses 0-based index. In this example, the 6-th and 7-th prices are 21.1790 and 64.0800, respectively. The program finds the maximum profit of 42.901
Use divide and conquer strategy to design your program. Explain in English your design and present pseudo code. If your program passes all the test cases and has a time complexity of (n log n), you will receive credit.
Partial credit will be given if your program passes all test cases and has a time complexity of (i.e., a brute force algorithm). Extra credit will be awarded if you implement a linear time ((n)) divide and conquer algorithm. Additional extra credit will be awarded if you implement a (n) decrease and conquer algorithm. Note that you will only receive partial credit if you transform this project into a problem that has a well-known divide and conquer solution.
Please submit JAVA source file and .jar file
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
