- We are given an array of price predictions for
m
stocks forn
consecutive days. The price of stocki
for dayj
isA[i][j] for i = 1,...,m & j = 1,...,n.
- You are tasked with finding the maximum possible profit by buying and selling stocks. The predicted price on any day will always be a non-negative integer. You can hold only one share of one stock at a time.
- You are allowed to buy a stock on the same day you sell another stock. More formally,
- Given a matrix
A
ofm × n
integers (non-negative) representing the predicted prices of m stocks forn
days, find a single transaction (buy and sell) that gives maximum profit.
- Given a matrix
A
ofm × n
integers (non-negative) representing the predicted prices of m stocks forn
days and an integerk
(positive), find a sequence of at mostk
transactions that gives maximum profit. [Hint:- Try to solve fork = 2
first and then expand that solution.]
- Given a matrix
A
ofm × n
integers (non-negative) representing the predicted prices ofm
stocks forn
days and an integerc
(positive), find the maximum profit with no restriction on number of transactions. However, you cannot buy any stock forc
days after selling any stock. If you sell a stock at dayi
, you are not allowed to buy any stock until dayi+c+1
Algorithm | Time Complexity | Description |
---|---|---|
1 |
O(m*(n^2)) |
Required. Brute Force for problem I |
2 |
O(m*n) |
Required. Greedy for problem I |
3 |
O(m*n) |
Required. Dynamic Programming for problem I |
4 |
O(m*(n^(2k))) |
Required. Brute Force for problem II |
5 |
O(m*(n^2)*k) |
Required. Dynamic Programming for problem II |
6 |
O(m*n*k) |
Required. Dynamic Programming for problem II |
7 |
O(m*(2^n)) |
Bonus. Brute Force for problem III |
8 |
O(m*(n^2)) |
Bonus. Dynamic Programming for problem III |
9 |
O(m*n) |
Bonus. Dynamic Programming for problem III |
- Problem pdf:
COT5405ProgrammingAssignmentFall2022.pdf
- Solution pdf:
AOA_FINAL_REPORT.pdf
- Clone the repository:
git clone https://github.com/d3v-26/AOA_Project.git
cd AOA_Project
-
Find Design and input requirements of each problem here:
AOA_FINAL_REPORT.pdf
-
Run the application using the following steps:
cd ScriptForThunderServer
g++ <FILE_TO_RUN>.cpp
- Refer to
makefile
for any custom automated inputs.