Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

What is the corresponding dynamic program in c language that uses the following pseudocode? Make-Change(d,n) For i 1 to n Do c[i] infinity For j

What is the corresponding dynamic program in c language that uses the following pseudocode?

Make-Change(d,n)

  1. For i 1 to n
  2. Do c[i] infinity
  3. For j 1 to k
  4. Do if i>=d
  5. Then if 1+c[i-dj]
  6. Then c[i] 1+c[i-dj]
  7. Denom[i] dj
  8. Return c and denom

Line 8 returns two arrays c and denom. c[n] gives the minimum number of coins require to represent the n cents. Using denom and tracing the array backward from the index n, the denominations of the coins used to represent the n cents, can be obtained.

The outer for loop runs n times and the inner for loop runs k times, so the total running time is O(nk).

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_2

Step: 3

blur-text-image_3

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

More Books

Students also viewed these Databases questions

Question

1. What makes Zipcar an attractive employer for whom to work?

Answered: 1 week ago

Question

107 MA ammeter 56 resistor ? V voltmeter

Answered: 1 week ago

Question

Generally If Drug A is an inducer of Drug B , Drug B levels will

Answered: 1 week ago