Computer Science, asked by mathewvaidyan4365, 10 months ago

Given two arrays a & b of size n each. Find the maximum n elements from the sum combinations (ai + bj) formed from elements in array a and b. For example if a = [1,2], b = [3,4], then po

Answers

Answered by Anonymous
0

Answer:

Initialize the heap with the maximum possible sum combination i.e (A[N – 1] + B[N – 1] where N is the size of array) and with the indices of elements from both arrays (N – 1, N – 1). The tuple inside max heap will be (A[N-1] + B[N – 1], N – 1, N – 1). Heap is ordered by first value i.e sum of both elements. 4.

Similar questions