Your friend is a competitive eater and they have solicited your help for upcoming cookie eating...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Your friend is a competitive eater¹ and they have solicited your help for upcoming cookie eating competition. The rules of the contest are simple; they must eat n cookies as quickly as possible. However, the tricky part is figuring out which cookies they should eat. There are m different types of cookies, and oddly enough your friend finds that when they eat too many of one type of cookie it slows them down. Having done some practicing, they have determined for any cookie type i and any number of cookies j, how long it will take them to eat j cookies of type i. This information is stored in the form of a list C;[1,...,n] for each type of cookie i, where C:[j] is the amount of time it takes your friend to eat j cookies of type i. You observe that C;[j] is increasing with increasing j for all i. You will use dynamic programming to determine how many cookies of each type your friend should eat so that the total time it takes to eat n cookies is minimized. (a) Describe the set of subproblems that your dynamic programming algorithm will consider. Your solution should look something like "For every..., we define OPT[...] to be ...". Solution: (b) Give a recurrence expressing the solution to each subproblem in terms of the solution to smaller subproblems. Solution: (c) Using your recurrence, design a dynamic programming algorithm to output the optimal distribution of the n cookies over the m types. You may use either a top-down or bottom- up approach. Remember that your algorithm needs to output the optimal distribution of cookies. The output of your algorithm can be an array of length m where the ith entry gives the number of cookies of type i. The running time of your algorithm must be polynomial in n and m. Be sure to describe any auxiliary variables which you use. You should include both pseudocode and a description of your algorithm. Solution: (d) Analyze the running time and space usage of your algorithm. Provide brief justification of each. Your friend is a competitive eater¹ and they have solicited your help for upcoming cookie eating competition. The rules of the contest are simple; they must eat n cookies as quickly as possible. However, the tricky part is figuring out which cookies they should eat. There are m different types of cookies, and oddly enough your friend finds that when they eat too many of one type of cookie it slows them down. Having done some practicing, they have determined for any cookie type i and any number of cookies j, how long it will take them to eat j cookies of type i. This information is stored in the form of a list C;[1,...,n] for each type of cookie i, where C:[j] is the amount of time it takes your friend to eat j cookies of type i. You observe that C;[j] is increasing with increasing j for all i. You will use dynamic programming to determine how many cookies of each type your friend should eat so that the total time it takes to eat n cookies is minimized. (a) Describe the set of subproblems that your dynamic programming algorithm will consider. Your solution should look something like "For every..., we define OPT[...] to be ...". Solution: (b) Give a recurrence expressing the solution to each subproblem in terms of the solution to smaller subproblems. Solution: (c) Using your recurrence, design a dynamic programming algorithm to output the optimal distribution of the n cookies over the m types. You may use either a top-down or bottom- up approach. Remember that your algorithm needs to output the optimal distribution of cookies. The output of your algorithm can be an array of length m where the ith entry gives the number of cookies of type i. The running time of your algorithm must be polynomial in n and m. Be sure to describe any auxiliary variables which you use. You should include both pseudocode and a description of your algorithm. Solution: (d) Analyze the running time and space usage of your algorithm. Provide brief justification of each.
Expert Answer:
Answer rating: 100% (QA)
This problem can be solved using dynamic programming Lets break down the solution into the requested ... View the full answer
Related Book For
Organizational Behaviour Concepts Controversies Applications
ISBN: 978-0132310314
6th Canadian Edition
Authors: Nancy Langton, Stephen P. Robbins, Timothy A. Judge, Katherine Breward
Posted Date:
Students also viewed these programming questions
-
6 C Use a Periodic Table of Elements to fill in the chart below, noting any and all trends in the student notes section provided. 3 Li Lithium Carbon 10 30 Zn Ne Neon Zinc 20 65 12 3 protons 4...
-
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...
-
List three specific parts of the Case Guide, Objectives and Strategy Section (See below) that you had the most difficulty understanding. Describe your current understanding of these parts. Provide...
-
Rewe Company's income statement contained the condensed information below. Rewe's balance sheets contained the following comparative data at December 31. Accounts payable pertain to operating...
-
Is it possible to temper an oil-quenched 4140 steel cylindrical shaft 50 mm (2 in.) in diameter so as to give a minimum tensile strength of 900 MPa (130,000 psi) and a minimum ductility of 20%EL? If...
-
If you buy a new car for $20,000 today and then try to sell it a week later, you probably won t get more than $16,000 for it. Even if you drove it just a couple of hundred miles, cleaned it up, and...
-
Determine the maximum percent error of a vibrometer in the frequency-ratio range \(4 \leq r
-
Fordyce Electronics issues a $400,000, 8%, 10-year mortgage note on December 31, 2009. The proceeds from the note are to be used in financing a new research laboratory. The terms of the note provide...
-
You have a ball bearing and a bowl.You let the ball roll down from the top of the ball; it moves up and down the bowl's wall for some time. (a) Is this vibrational motion? explain why or why not. (b)...
-
On July 1, the ABC Partnership, a calendar-year partnership, distributes to each of its equal partners $10,000 cash and land with a value of $10,000 and a basis of $5,000. A, B and C have outside...
-
Integrated Ltd purchased 69500 shares in a company listed on the JSE. The shares acquired on 1 June 2018, were acquired when the share price was R3.40 per share. Integrated had to pay brokers...
-
Calculate the price elasticity of demand for gasoline implied by what most studies have found. Why the tepid response to higher gasoline prices? Most studies report that when U.S. gasoline prices...
-
Which of the following utility functions are consistent with weak complementarity? a. b. c. d. e. U(x,z,q) =YxIn(x-8(q) + 0)+In z, 4,0>0, 8(q)>0
-
Apple and Samsung have two pricing strategies: Set a high (monopoly) price or set a low (competitive) price. Suppose that if they both set a competitive price, economic profit for both is zero. If...
-
The Wake County database contains a variable lakedist, which measures the distance (in hundreds of meters) from the property to the nearest lake. Consider using this variable to proxy the value of...
-
Explain why, if Max equalized the marginal utility per hour from windsurfing and from snorkeling, he would not maximize his utility.
-
During the month of March 2022 the company John Services, Ltd. realized the following transactions March 1, Paid a 12 month insurance policy for $36,000 March 2: Paid the employee $44,000 for their...
-
B.) What is the approximate concentration of free Zn 2+ ion at equilibrium when 1.0010 -2 mol zinc nitrate is added to 1.00 L of a solution that is 1.080 M in OH - . For [Zn(OH) 4 ] 2- , K f = 4.610...
-
Do you think most employees prefer high formalization? Support your position.
-
How does a strong culture affect an organizations efforts to improve diversity?
-
Job redesign is a way of exploiting employees by increasing their responsibilities. Comment on this statement, and explain whether you agree with it or not.
-
Use the existing pattern in this chapter to model a student email account. a. Draw a class diagram of using Any Account pattern. b. Generate a significant use case for this context. c. Map the use...
-
What characteristics do you check for each BO?
-
How do you apply a stable analysis pattern to a particular context?
Study smarter with the SolutionInn App