You are given a sequence of n items such that each itemi has value vi and if you buy item j youcan not buy items j + 1 or j + 2. Your goal is tomaximize the sum of the values of all the items purchased.
Give an O(n) runtime algorithm to find a set of items fittingthese criteria, prove the correctness of your algorithm, andanalyze its runtime.
Part 2 grading:
[10 points] Algorithm: Your algorithm generally has a correctidea and has a runtime of O(n)
[20 points] Correctness Proof: Your algorithm is correct on allinputs, has a runtime of O(n), and your proof
PayPal Gateway not configured
PayPal Gateway not configured