Consider the following problem. Given n positive integers a₁, a₂,...,aₙ, it is…
PYQ GATE 1990
Consider the following problem. Given n positive integers a₁, a₂,...,aₙ, it is required to partition them in to two parts A and B such that |Σ(i∈A)aᵢ − Σ(i∈B)aᵢ| is minimised.
Consider a greedy algorithm for solving this problem. The numbers are ordered so that a₁ ≥ a₂ ≥ ... ≥ aₙ, and at i-th step, aᵢ is placed in that part whose sum is smaller at that step. Give an example with n=5 for which the solution produced by the greedy algorithm is not optimal.
Attempted by 1 students.
Sign up free to check your answer
Sign up freeLoading lesson…

