Algorithm that finds the maximum such sum


Assume you have an array of numbers, where each value occurs at most twice.
We consider sums of contiguous numbers in the array. But we only consider such sums whose two endpoints have the same value. The sum includes the two equal values themselves. So if the two equal numbers are at index i and index j (i < j) in array A, then we sum all the values A[i],A[i + 1], . . . ,A[j].

(a) Give an algorithm that finds the maximum such sum. Make your algorithm as efficient as possible. Describe the algorithm briefly in English and in psuedo code.

(b) Analyze the running time of your algorithm.

Request for Solution File

Ask an Expert for Answer!!
Data Structure & Algorithms: Algorithm that finds the maximum such sum
Reference No:- TGS092052

Expected delivery within 24 Hours