ALGORITHMS FINAL 1. (60 pts.) Imagine a thief entering a house. In the house, there are...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
ALGORITHMS FINAL 1. (60 pts.) Imagine a thief entering a house. In the house, there are infinitely many items that can have only one of three different weights: 1 kg, 3 kgs, and 5 kgs. All of the items are discrete. The thief has a bag capacity of n kgs and strangely, he wants to steal the "smallest number of items". (a) (10 pts.) Give a mathematical recursive formulation for C(n) where C(n) denotes the smallest number of items the thief can steal using a bag capacity of n. (b) (5 pts.) Show that this problem has the overlapping subproblems property. (c) (15 pts.) Write a recursive algorithm (as a pseudocode) that returns the smallest number of items the thief can steal using a bag capacity of n. (d) (5 pts.) Show that the greedy choice of taking the largest weight items into the bag first fails to lead to an optimal solution. (e) (15 pts.) Write a dynamic programming algorithm (as a pseudocode) for finding the smallest number of items the thief can steal using a bag capacity of n. (f) (10 pts.) Provide the running time of your dynamic programming algorithm. Explain. ALGORITHMS FINAL 1. (60 pts.) Imagine a thief entering a house. In the house, there are infinitely many items that can have only one of three different weights: 1 kg, 3 kgs, and 5 kgs. All of the items are discrete. The thief has a bag capacity of n kgs and strangely, he wants to steal the "smallest number of items". (a) (10 pts.) Give a mathematical recursive formulation for C(n) where C(n) denotes the smallest number of items the thief can steal using a bag capacity of n. (b) (5 pts.) Show that this problem has the overlapping subproblems property. (c) (15 pts.) Write a recursive algorithm (as a pseudocode) that returns the smallest number of items the thief can steal using a bag capacity of n. (d) (5 pts.) Show that the greedy choice of taking the largest weight items into the bag first fails to lead to an optimal solution. (e) (15 pts.) Write a dynamic programming algorithm (as a pseudocode) for finding the smallest number of items the thief can steal using a bag capacity of n. (f) (10 pts.) Provide the running time of your dynamic programming algorithm. Explain.
Expert Answer:
Answer rating: 100% (QA)
This looks like an exam question about algorithms specifically focusing on recursion greedy algorithms and dynamic programming Heres a stepbystep brea... View the full answer
Related Book For
Computer Architecture A Quantitative Approach
ISBN: 978-0123704900
4th edition
Authors: John L. Hennessy, David A. Patterson
Posted Date:
Students also viewed these programming questions
-
Determine the correct form for trial y. DO NOT SOLVE the differential equation. 2x y9y+14y=3x-5sinx + 7xe P
-
In the figure there are infinitely many circles approaching the vertices of an equilateral triangle, each circle touching other circles and sides of the triangle. If the triangle has sides of length...
-
Googles ease of use and superior search results have propelled the search engine to its num- ber one status, ousting the early dominance of competitors such as WebCrawler and Infos- eek. Even later...
-
ABC Pty Ltd would like to set up a Virtualisation Platform on their organisation. You have been hired by Company to be their network and system administrator to implement virtualisation for...
-
Sturdy Bike Company makes the frames used to build its bicycles. During 2018, Sturdy made 20,000 frames; the costs incurred follow: Unit-level materials costs (20,000 units $35.00)..........$...
-
Repeat Problem 63 for R L = 3.3 k and the average value of h oe in Fig. 5.92. Fig. 5.92 Min. Max. Input impedance (dc 1 mA de, VcE = 10 V dc, f = 1 kHz) Voltage feedback ratio (lc = 1 mA de, VCE = 10...
-
What must be included in a separate statement?
-
Reitmans (Canada) Limited is a leading Canadian retailer that operates more than 900 stores under the Reitmans, Smart Set, RW & Co., Thyme Maternity, Penningtons, and Addition Elle banners. The...
-
Roman Hernandez saw the following advertisement for a used Volkswagen bug and decided to work out the numbers to be sure that add had no errors cash price 8 0 0 0 down payment zero dollars annual...
-
On August 1, 2016, Stephanie Ram, a sole proprietor, started a new business, Ram Wholesale Company. The company sells refrigerators (merchandise) to various retail stores and uses the periodic...
-
Which of the following commands sets the secret password to Cisco? A.enable secret password Cisco B.enable secret cisco C.enable secret Cisco D.enable password Cisco
-
Beto Company pays $4.70 per unit to buy a part for one of the products it manufactures. With excess capacity, the company is considering making the part. Making the part would cost $4.50 per unit for...
-
Amy made 35,000 in taxable income less year supposed the income tax rate is 15% for the first 7500plus 19% for the amount over 7500. How much must Amy pay in income tax for last year
-
Case #1 Palace Inc. manufactures two product lines (Deluxe and Standard). Currently, the company allocates overhead costs to the product lines based on direct labour hours. For 2021, the company...
-
A tennis ball located 2.0 m height is hit by a player with his racket. The ball shoots out horizontally with a velocity of 30 m/s. Answer the following questions: a. How long does the ball takes to...
-
What is the concept of time value of money, and why is it important in finance? 2. What are the key differences between stocks and bonds as investment options? 3. How does diversification help in...
-
Logistics Processes Exam: ProVideo Technologies A year ago you were hired as the Logistics Manager for ProVideo Technologies (PVT) in Canada. PVT is a reseller of mobile video camera equipment...
-
Simplify the expression. Assume that all variables are positive. 23VI1 2 V44 8
-
Figure 1.22 gives the relevant chip statistics that influence the cost of several current chips. In the next few exercises, you will be exploring the trade-offs involved between the AMD Opteron, a...
-
For the following code sequences and the timing parameters for the two implementations in Figure 4.38, compute the total stall cycles for the base MSI protocol and the optimized MOSI protocol in...
-
In a server farm such as that used by Amazon or the Gap, a single failure does not cause the whole system to crash. Instead, it will reduce the number of requests that can be satisfied at any one...
-
Briefly explain the connections between values such as effort optimism, utilitarian individualism, and the American economic system. Throughout this chapter, we have identified culture as something...
-
Do you speak a language other than English as a first language? If so, do you want your children and grandchildren to speak that language? In the United States, the tools of government and education...
-
If English is your first language, did your parents or grandparents speak a different first language? How do you feel about your ability (or lack of ability) in that language? In the United States,...
Study smarter with the SolutionInn App