Ask Question
18 September, 13:21

suppose that you are given two sets A and B, each containing positive integers. You can choose to reorder each set however you like. After reordering, letaibe theith element of set A, and letbibe theith element of set B. You then receive a payoff of∏ni=1abii. Givea polynomial-time algorithm that will maximize your payoff. Prove that your algorithm maximizes the payoff, and state its running time.

+4
Answers (1)
  1. 18 September, 13:48
    0
    We solve the problem with the following algorithms:

    1. Order A is in the increasing order.

    2. Order B is in the decreasing order.

    3. Return (A, B).

    Explanation:

    We need to show that this gives an optimal solution. without the loss of the generality, we can assume that a₁ ≤ a₂ ... ≤ aₙ in the optimal solution. Since the payoff is / prod_{i}^{n}=1^{a_{i}^{bi}}, the payoff will always increase if we make a change so that b_{i+1} > b_{i}. Therefore the optimal solution will be found if B is sorted.

    The running time is O (n log (n)) since we sort two vector.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “suppose that you are given two sets A and B, each containing positive integers. You can choose to reorder each set however you like. After ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers