Monday, 15 September 2014

algorithm - Maximum of sums of unsorted array and each of a number of sorted arrays -



algorithm - Maximum of sums of unsorted array and each of a number of sorted arrays -

given unsorted array

a = a_1 ... a_n

and set of sorted arrays

b_i = b_i_1 ... b_i_n # 1 $large_number

i find maximums (not yet calculated) sum arrays

c_i = (a_1 + b_i_1) ... (a_n + b_i_n)

for each i.

is there trick improve calculating c_i , finding maximums in o($large_number * n)?

can improve when know b arrays shifts endless sequence, e.g.

s = 0 1 4 9 16 ... b_i = s[i:i+n]

(the above sequence has maybe advantageous property (s_i - s_i-1 > s_i-1 - s_i-2))

there $large_number * n info in first problem, there can't such trick.

you can prove adversary argument. suppose have algorithm solves problem without looking @ n * $large_number entries of b. i'm going pick fixed a, namely (-10, -20, -30, ..., -10n). first $large_number * n - 1 algorithm looks @ entry b_(i,j), i'll reply it's 10j, sum of zero. lastly time looks @ entry, i'll reply it's 10j+1, sum of 1.

if $large_number omega(n), sec problem requires @ n * $large_number entries of s, can't have such trick.

however, if specify s, there may something. , if $large_number <= n/2 (or whatever is), then, of entries of s must sorted, have @ lastly b.

algorithm sorting

No comments:

Post a Comment