questionsuppose you have an array of numbers


Question

Suppose you have an array of numbers, where each value occurs at most twice.

We consider sums of contiguous numbers in array. But we only consider such sums whose two endpoints have the similar value. The sum includes the 2 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 maximum such sum. Make your algorithm as efficient as possible. Explain the algorithm briefly in English and in psuedo code.

(b) Analyze running time of your algorithm.

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: questionsuppose you have an array of numbers
Reference No:- TGS0444561

Expected delivery within 24 Hours