Question: Programming Project 1 Divide and Conquer In this project, our input is an array of doubles, where each entry A[i] denotes the price of

![an array of doubles, where each entry A[i] denotes the price of](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/01/65ba45de1b72f_39765ba45dde3ce3.jpg)
Programming Project 1 Divide and Conquer In this project, our input is an array of doubles, where each entry A[i] denotes the price of a stock (or some other asset) on the ith day. So for example, if A = [5, 2, 3, 6, 1, 3] then this means that the stock in question was worth 5 on day 0, it was worth 3 on day 2, etc. We will consider buying the stock once and then later selling it once (of course we must sell the stock after we have bought it). If we buy the stock on buyDay and we sell the stock on sellDay, then the goal is to maximize our profit A[sellDay] - A[buyDay]. In the example above, the optimal solution is for buyDay to be 1 (buying at the price A[1] = 2) and sell Day to be 3 (selling at the price A[3] = 6). This gives us a profit of 4. Stating the parameters formally: We must sell on a different day than we buy, and we must sell after we buy. In other words, we must have buyDay < sellDay. This means that if A has Since everyone is coding in their own preferred language, we are asking you to provide a bash script named project1.sh that will act similarly to a makefile. I covered how bash scripts work in class in the Project 1 overview lecture, and I recorded a short follow-up to this here: https://youtu.be/CalFJWiyU U In short, your bash script should contain the command to compile your code, and then on a different line, it should contain the line to execute your code. There are several input files for you to test your code on, and the bash script should take a command line argument specifying which input file to run on. So, the command to execute your code should look like this: bash project1.sh input.txt See the YouTube video that I linked for more details on how to use command line arguments inside a bash script. Files provided in the project: Since you are programming in different languages, we are providing no source files for your code. We have provided a blank project1.sh file for you to fill in as well as several input files for you to test your code on. Each input file contains a single price on each line of the file. The first line should be index 0 of your array, the second line should be index 1, etc. We will test your code will all the privided input files, but we will also be testing with some different input files that will be in the same format. Some of these files may be very large (hundreds of thousands of entries).
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
