You have n identical flowers, which you would like to place intok vases, according to the following rules: • Each flower must beplaced in a vase. • The ith vase (where 1 ≤ i ≤ k) must contain atleast 1 and at most fi flowers. • No two vases are allowed tocontain the same number of flowers. Your goal is to assign a numberof flowers to each vase following the above rules, or to determinethat no such assignment exists. 1.1 [10 marks] Suppose that f1 = .. . = fk = n. Design an algorithm which runs in O(k) time andachieves the goal. 1.2 [10 marks] Now we return to the originalproblem, in which the fi can take any positive integer values.Design an algorithm which runs in O(k log k) time and achieves thegoal.
explain in words not in code
You have n identical flowers, which you would like to place into k vases, according to the following rules: • Each flowe
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am