Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 3. Suppose you are a teller and the currency in your country is arranged in coins of increasing C values (each coin has a

Problem 3.

Suppose you are a teller and the currency in your country is arranged in coins of increasing C values (each coin has a value of a power of C for some integer C > 1), i.e., you have coins of 1, C, C^(2), ..., C^(k) up to some k >= 1. Your customer wants you to make change for N (N is a positive integer) using the minimum number of coins. Propose an efficient greedy algorithm in pseudocode which returns k +1 numbers 20, 21 : 12... such that (i)image text in transcribed and (ii) the total number of coins used, image text in transcribed , is minimized. Prove that your algorithm is guaranteed to always return the optimal solution, that is, condition (ii) is always satised. (Hint: Prove the two properties, subproblem optimality and substitution property, required for a greedy algorithm to work.)

N = -? niC

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

Students also viewed these Databases questions