Question
Recursive & Non Recursive way to compute maximum Profit The thirty days price of a stock is given as blow: Day 1: 8108, Day 2:
Recursive & Non Recursive way to compute maximum Profit
The thirty days price of a stock is given as blow:
Day 1: 8108, Day 2: 8108, Day 3: 8108, Day 4: 8108, Day 5: 8108, Day 6: 8108, Day 7: 8108, Day 8: 8108, Day 9: 8108, Day 10: 8108, Day 11: 8108, Day 12: 8108, Day 13: 8108,
Day 14: 8108, Day 15: 8108, Day 16: 8108, Day 17: 8108, Day 18: 8108, Day 19: 8108, Day 20: 8108, Day 21: 8108, Day 22: 8108, Day 23: 8108, Day 24: 8108, Day 25: 8108,
Day 26: 8108, Day 27: 8108, Day 28: 8108, Day 29: 8108, Day 30: 8108
Requirements:
- Formulate an efficient recursive algorithm using Divide and Conquer to find the buy date and sell date to maximize profit
- Also develop a non-recursive, linear-time algorithm for the above problem.
- Analyse the time complexity for requirement
- Implement the above problem statement using Python 3.7
Sample Input:
Input should be taken in through a file called inputPS13.txt which has the fixed format mentioned below using the / as a field separator:
/
Ex.
1 / 8108
2 / 8146
3 / 8116
Sample Output:
Maximum Profit (Divide & Conquer solution): 539
Day to buy: 8
Day to sell: 12
Maximum Profit (Iterative solution): 539
Day to buy: 8
Day to sell: 12
Note that the output data shown here is only for understanding and testing, the actual file used for evaluation will be different. The output need not match the sample input provided earlier.
The output should be written to the file outputPS13.txt
Deliverables
- algorithm design and time complexity of the algorithm.
- inputPS13.txt file used for testing, you can copy paste just like the reference question
- outputPS13.txt file generated while testing
Key Points
a. It is compulsory to make use of the data structure(s) / algorithms mentioned in the problem statement.
b. Use only native data types like lists and tuples in Python. Use of libraries like graph, numpy, pandas library etc. is not allowed. The purpose is to understand how these data structures are constructed and how they work internally.
c. It is compulsory to use Python 3.7 for implementation.
d. Ensure that all data structure insert and delete operations throw appropriate messages when their capacity is empty or full.
e. Ensure that the input, prompt and output file guidelines are adhered to. Deviations from the mentioned formats will not be entertained.
f. Run time analysis is provided in asymptotic notations and not timestamp based runtimes in sec or milliseconds.
Reference
Similar exercise was previously solved by one of the Chegg Expert, please refer below link:
https://www.chegg.com/homework-help/questions-and-answers/1-problem-statement-government-hospital-treating-patients-covid-management-preparing-token-q52072278?trackid=weD0wjEN
===============
Kind Attention to Chegg Team: Please assign this question to one of the CHEGG Expert (not to beginners and intermediate folks), main reason every time I post a question some beginner write a comment stating "need more info"but they won't mention what info is required. My further subscription to chegg study depends on how Chegg team handles this question, I have also given reference where one of your previous expert answered similar question
=============================
To Chegg Team: I have found the answer through Slader, as expected everyone coming and writing some comments but nothing useful to the Question owner.Instead Chegg doing audit on account owners you should do audit on who ever comes and posts redundant comments
As I mentioned I'm not going to subscribe to Chegg any more
=========================
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started