(50 MARKS) (Greedy Algorithms.) A group of friends is organizing a bike racing competition. There are n friends and m bikes, but bikes ate not equal, some of them perform better and some of them perform worse. You may think that each bike has a performance factor pi, 1 ≤ i ≤ m in the range (1,100) where 1 is the worst and 100 is the best. Each frieng has a greed factor 9i, 1 ≤ i ≤ n which is the minimum bike performace this firend will be content with. Your goal is to maximize the number of content friends, i.e., friends i assigned a bike j with gi ≤ pj. Give a correct greedy algorithm for this problem (15 marks), prove that it finds the optimal solution (20 marks), and give an efficient implementation (15 marks).
(50 MARKS) (Greedy Algorithms.) A group of friends is organizing a bike racing competition. There are n friends and m bikes, but bikes ate not equal, some of them perform better and some of them perform worse. You may think that each bike has a performance factor pi, 1 ≤ i ≤ m in the range (1,100) where 1 is the worst and 100 is the best. Each frieng has a greed factor 9i, 1 ≤ i ≤ n which is the minimum bike performace this firend will be content with. Your goal is to maximize the number of content friends, i.e., friends i assigned a bike j with gi ≤ pj. Give a correct greedy algorithm for this problem (15 marks), prove that it finds the optimal solution (20 marks), and give an efficient implementation (15 marks).
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps