You have n identical flowers, which you would like to place into k vases, according to the following rules: • Each flowe
Posted: Sun Jul 03, 2022 12:01 pm
You have n identical flowers, which you would like to place intok vases, according to the following rules:
• Each flower must be placed in a vase.
• The ith vase (where 1 ≤ i ≤ k) must contain at least 1 andat most fi flowers.
• No two vases are allowed to contain the same number offlowers. Your goal is to assign a number of flowers to each vasefollowing the above rules, or to determine that no such assignmentexists.
Question: given that fi can take any positive integervalues, Design an algorithm which runs in O(klogk) time andachieves the goal with explanation.
• Each flower must be placed in a vase.
• The ith vase (where 1 ≤ i ≤ k) must contain at least 1 andat most fi flowers.
• No two vases are allowed to contain the same number offlowers. Your goal is to assign a number of flowers to each vasefollowing the above rules, or to determine that no such assignmentexists.
Question: given that fi can take any positive integervalues, Design an algorithm which runs in O(klogk) time andachieves the goal with explanation.