COMP3023语言程序 写作、C++编程调试

” COMP3023语言程序 写作、C++编程调试COMP3023 Programming AssignmentShooting CompetitionPhiloctetes is a sharp shooter. One day he is invited by a shooting competition.In the competition, each shooter is given an array of n targets. Every targethas a value, a positive integer. If one target t is shot, the shooters scores willbe increased byv1 v2 v3where v1 is the value on the Target t, v2 is the value on ts left neighbor, and v3is the value on ts right neighbor.You need to design a Greed algorithm and a dynamic programming algorithmto find an shooting order to maximize the score earned by Philoctetes under thefollowing assumptions.1. Philoctetes never misses any target.2. Shooters know the value on every target before shooting.3. Each target has only two neighbors, left and right.4. If one target is shot, its left and right neighbors will be neighbors afterwards.5. Pretend that the first target has an artificial left neighbor – target 0.Philoctetes cannot shoot target 0, but the target has value 1 and will becounted in the score calculation.6. Similarly, the right nieghbor of the last target is also an artificial targetn + 1 of value 1, which cannot be shot.Requirements1. Algorithms(a) The greedy algorithm runs in O(n log n) time and uses O(1) space.The greedy algorithm is not required to always find the maximumscore.(b) The dynamic programming runs in O(n2) time and uses O(n2) space.It always gives the maximum score.12. Program(a) You need to implement your algorithms in C.(b) Your program reads a test case from input.txt.(c) input.txt only contains the values for each target, one value oneach line.(d) Your program Outputs the resulting score on the screen and the correspondingshooting sequence to output.txt, one index of a targeton each line.3. Report(a) Your report should contain all the notations that you have used tomodel the problem,(b) the recurrent relation for the dynamic programming,(c) step-by-step pseudo codes for the two algorithms with clearly describedinputs and outputs,(d) an instance Such that your greedy algorithm cannot find the maximumsolution,(e) space and time Complexity anlysis of your algorithms.(f) Your report should be 2 to 3 pages long, depends how you write.4. Submission includs your code and your report. Name the package asCOMP3023 20F PA #########.zip, where #########is your Student ID.ExampleSuppose Philoctetes is given 4 targes of values 2, 1, 4, 3 (see input example.txt),the maximum score is 41 becauseIteration Target index Score Values of the remaining targets1 Target 2 (valued 1) 0 + 2 1 4 2, 4, 32 Target 3 (valued 4) 8 + 2 4 3 2, 33 Target 1 (valued 2) 32 + 1 2 3 34 Target 4 (valued 3) 38 + 1 3 1 EmptyThe shooting sequence 2, 3, 1, 4 is in output example.txt.如有需要,请加QQ:99515681 或邮箱:99515681@qq.com

添加老师微信回复‘’官网 辅导‘’获取专业老师帮助,或点击联系老师1对1在线指导