Question: Algorithm homework please help me 2. (20 points) The Battery Assignment Problem. You have n robots (r1, T2, ..., In) and m batteries where m

Algorithm homework please help me
2. (20 points) The Battery Assignment Problem. You have n robots (r1, T2, ..., In) and m batteries where m > n. Each robot ri requires ki batteries to operate and if it is given less than that, it will not function. The goal of this problem is to assign batteries to robots such that the number of operational robots is maximized. For example, if we have 10 batteries and 4 robots where robot r requires k = 5 batteries, r2 requires k2 = 2 batteries, r3 requires k3 = 4 batteries, and r4 requires r4 = 3 batteries then one possible optimal solution is to give those batteries to (T1, T2, r4) since that will operate 3 robots. If instead you gave the batteries to (11,83) then you will not have enough to operate other robots so this solution is not optimal. Note that you may not need to use all the batteries in your optimal assignment. (a) (10 points) Devise a greedy algorithm (in pseudocode) that solves this problem for any set of n robots and m batteries. Clearly state your greedy choice and running-time of your algorithm. (b) (Bonus: 10 points) Prove that your algorithm always gives the optimum solution by showing the optimal substructure and greedy-choice properties
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
