You are given a sequence of n items such that each item i has value vi and if you buy item j youcan

You are given a sequence of
n items such that each item
i 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 of correctness islogically sound and complete [5 points] Runtime Analysis: Your algorithm has a runtime ofO(n) and you correctly analyzed the runtime of your algorithm [20 points] Implementation: You correctly implemented youralgorithm in code and the implementation is correct on all inputswith runtime O(n) . . .