Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2. In a previous life, you worked as a cashier in the lost Antarctican colony of Nadira, spending the better part of your day giving

image text in transcribed

2. In a previous life, you worked as a cashier in the lost Antarctican colony of Nadira, spending the better part of your day giving change to your customers. Because paper is a very rare and valuable resource in Antarctica, cashiers were required by law to use the fewest bills possible whenever they gave change. Thanks to the numerological predilections of one of its founders, the currency of Nadira, called Dream Dollars, was available in the following denominations: $1, $4, $7, $13, $28, $52, $91, $365.1 (a) The greedy change algorithm repeatedly takes the largest bill that does not exceed the target amount. For example, to make $122 using the greedy algorithm, we first take a $91 bill, then a $28 bill, and finally three $1 bills. Give an example where this greedy algorithm uses more Dream Dollar bills than the minimum possible. [Hint: It may be easier to write a small program than to work this out by hand.] (b) Describe a recursive algorithm that computes, given an integer k, the minimum number of bills needed to make k Dream Dollars. Express your running time using a recurrence relation. You do not need to solve the running time recurrence to get full credit. (And don't worry about making your algorithm fast; just make sure it's correct. We'll learn how to make it fast next week.)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Guide To Client Server Databases

Authors: Joe Salemi

2nd Edition

1562763105, 978-1562763107

More Books

Students also viewed these Databases questions

Question

=+applying to all or most employers and employees?

Answered: 1 week ago

Question

=+associated with political parties and if so, which ones? Are

Answered: 1 week ago