You have n identical flowers, which you would like to place into k vases, according to the following rules: • Each flowe

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

You have n identical flowers, which you would like to place into k vases, according to the following rules: • Each flowe

Post by answerhappygod »

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
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply