Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is for sn algorithms course. Write a function CHANGES( m ) (in psudocode), which returns a minimal number of coins to get a total

This is for sn algorithms course.

Write a function CHANGES(m) (in psudocode), which returns a minimal number of coins to get a total of m cents.

Constraints: There are four types of coins with values 1, 5, 10, and 25, respectively. The total amount of money m is within 199 cents.

Examples:

CHANGES(3) = 3: it takes at least 3 coins (1 cent each) to get a total of 3 cents.

CHANGES(6) = 2: it takes at least 2 coins (a 5-cent coin and 1-cent coin) to get a total of 6 cents.

CHANGES(99) = 9: it takes at least 9 coins (25 + 25 + 25 + 10 + 10 + 1 + 1 + 1 + 1) to get a total of 99 cents.

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

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

More Books

Students also viewed these Databases questions

Question

Describe the menstrual cycle in a woman.

Answered: 1 week ago

Question

Explain methods of metal extraction with examples.

Answered: 1 week ago