Consider the following Trick-or-Treat problem. You live on a street with n houses. You have a...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Consider the following Trick-or-Treat problem. You live on a street with n houses. You have a bag to carry your Halloween candy, but your bag can carry at most K ounces of candy. You are given for each house i, an integer weight w; (in ounces) of the candy that the people in house i are handing out. Each house gives out one piece of candy. You can visit each house at most once. Your problem is to collect the largest number of pieces of candy from the n houses without exceeding the capacity of your bag. Now consider the following greedy algorithm. Sort the houses according to the weight of the candy they are providing. Collect candy from the houses starting from the house that provides the lightest candy, then the next lightest, ... until your bag is full. a. State and prove a "swapping lemma" for this greedy algorithm. b. Write a proof that uses your swapping lemma to show that the greedy algorithm does indeed collect the largest number of pieces of candy without exceeding the weight of your bag. Note: You must show that it is not possible to collect more pieces of candy than the greedy algorithm. Do not appeal to any general principles. You must incorporate your swapping lemma as you stated. Consider the following Trick-or-Treat problem. You live on a street with n houses. You have a bag to carry your Halloween candy, but your bag can carry at most K ounces of candy. You are given for each house i, an integer weight w; (in ounces) of the candy that the people in house i are handing out. Each house gives out one piece of candy. You can visit each house at most once. Your problem is to collect the largest number of pieces of candy from the n houses without exceeding the capacity of your bag. Now consider the following greedy algorithm. Sort the houses according to the weight of the candy they are providing. Collect candy from the houses starting from the house that provides the lightest candy, then the next lightest, ... until your bag is full. a. State and prove a "swapping lemma" for this greedy algorithm. b. Write a proof that uses your swapping lemma to show that the greedy algorithm does indeed collect the largest number of pieces of candy without exceeding the weight of your bag. Note: You must show that it is not possible to collect more pieces of candy than the greedy algorithm. Do not appeal to any general principles. You must incorporate your swapping lemma as you stated.
Expert Answer:
Related Book For
Government and Not for Profit Accounting Concepts and Practices
ISBN: 978-1118155974
6th edition
Authors: Michael H. Granof, Saleha B. Khumawala
Posted Date:
Students also viewed these programming questions
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
"internet radios" for streaming audio, and personal video recorders and players. Describe design and evaluation processes that could be used by a start-up company to improve the usability of such...
-
Transactions related to revenue and cash receipts completed by Acheville Architects Co. during the period September 2-30, 2014, are as follows: Sept. 2. Issued Invoice No. 793 to Nickle Co., $5,200....
-
Tiger Company completed the following transactions during 2013. The annual accounting period ends December 31, 2013. Jan. 3 Purchased merchandise on account at a cost of $24,000. (Assume a perpetual...
-
In problem, solve each equation. 8 10 2x-7 = 3
-
CMS is a claims processing company in Mobile, Alabama. Chastity Jones, a black woman, completed an online employment application for a customer service position with CMS. Jones interviewed with a...
-
Ikerd Company applies manufacturing overhead to jobs on the basis of machine hours used. Overhead costs are expected to total $300,000 for the year, and machine usage is estimated at 125,000 hours....
-
Let 1 f(z) = (2-1)(x-2) Find the Laurent expansion of f about z = 0 in the region {ze C: 1
-
1. You are evaluating a project for a local private equity fund, and they have provided the data below. Considering that the value of a firm can be calculated as the sum of a series of cash flows...
-
You are the project manager in charge of renovating a large apartment building, and your team has decided to outsource the installation of a new septic system. Do you put out an RFQ or RFP to...
-
What five aspects of project success are evaluated in the balanced scorecard approach?
-
Which type of alliance might work best for a not-for-profit organization? For a for-profit organization? Why?
-
You decide to board your dog at the vets office while you are on vacation and sign papers saying you will pay $25 per day plus $15 for a bath every third day. What type of contract have you entered...
-
Why is it important as a project manager to help your team members secure follow-up work toward the end of your project?
-
Why riveting is preferred for aluminum alloys when compared with welds joint? T The bracket as shown in Fig. is to carry a load of 45 kN. Determine the size of the rivet if the shear stress is not to...
-
Write a declaration for each of the following: a. A line that extends from point (60, 100) to point (30, 90) b. A rectangle that is 20 pixels wide, 100 pixels high, and has its upper-left corner at...
-
Why are the problems of accounting for postemployment health care benets similar to those of accounting for pensions? Why, however, are they even more intractable?
-
In each of the following scenarios, an organization receives a contribution in kind. Prepare journal entries, as necessary, to give them accounting recognition. For each, tell why you made an entry...
-
Select the best answer. 1. Under the modied accrual basis of accounting, revenues cannot be recognized a. Until cash has been collected b. Unless they will be collected within 60 days of year-end c....
-
Souvenir Sales. The file SouvenirSales.csv contains monthly sales for a souvenir shop at a beach resort town in Queensland, Australia, between 1995 and 2001. [Source: Hyndman and Yang (2018).] Back...
-
Analysis of Canadian Manufacturing Workers Workhours. The time plot in Figure 18 . 22 describes the average annual number of weekly hours spent by Canadian manufacturing workers...
-
Toys R US Revenues. Figure 18 . 23 is a time plot of the quarterly revenues of Toys R US between 1992 and 1995 (thanks to Chris Albright for suggesting the use of these data, which are available in...
Study smarter with the SolutionInn App