Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 3 We have p houseplants in planters of various sizes $1, 52,..., Sp. The plants are getting too big and each plant has

 

Problem 3 We have p houseplants in planters of various sizes $1, 52,..., Sp. The plants are getting too big and each plant has to be replanted to a larger planter than the one it currently has. The good news is that we have r extra planters of sizes t, t,..., tr. Is it possible to replant the plants, one at a time, always putting the plant to a larger currently empty planter? Let n = p+r. Design an O(n log n) algorithm which decides whether such replanting is possible. 2 For example, for p = 4 and r = 2 and planters $,..., 84 = 1, 4, 3, 2 and t, t2 = 5,1 we can first move the plant in the planter of size 4 to the empty planter of size 5, then move the plant in the planter of size 3 to the now-empty planter of size 4, then move the plant in the planter of size 2 to the now-empty planter of size 3, and finally move the plant in the planter of size 1 to the now-empty planter of size 2. (We will be left with two empty planters of size 1 each.) Thus, for the input, the answer is YES. On the other hand, for input p = 3 and r = 1 and planters 81, 82, 83 = 2, 2, 2 and t = 3 the answer is NO.

Step by Step Solution

3.36 Rating (159 Votes )

There are 3 Steps involved in it

Step: 1

Given p plants and r extra planters the problem is equivalent to finding the smallest size of plante... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

International Financial Reporting A Practical Guide

Authors: Alan Melville

6th edition

1292200743, 1292200766, 9781292200767, 978-1292200743

More Books

Students also viewed these Human Resource Management questions

Question

summarize the history of work psychology;

Answered: 1 week ago

Question

What is level mixed-model sequencing and why is it important?

Answered: 1 week ago

Question

To what extent has technology had an impact on JIT/lean systems?

Answered: 1 week ago