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
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
Math,
5 months ago
Math,
5 months ago
Math,
5 months ago
Computer Science,
10 months ago
Accountancy,
10 months ago
Math,
1 year ago
Economy,
1 year ago
Physics,
1 year ago