Class Change

java.lang.Object
topics.greedy.Change

public class Change extends Object
GREEDY ALGORITHM PROBLEM: THE PROBLEM OF THE CHANGE OF MONEY It has an optimal solution in some cases. The idea (heuristic) is always give the higher currency value that is less than or equal to the amount left to return
Author:
vicegd
  • Constructor Summary

    Constructors
    Constructor
    Description
    Change(float[] coins, int[] solution)
    Constructor for Change objects
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    calculateCoins(double amount)
    Calculates the coins to be used to give a specific amount of money This method has a good complexity O(n)

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Change

      public Change(float[] coins, int[] solution)
      Constructor for Change objects
      Parameters:
      coins - Available coins to be used
      solution - Array to save the number of coins of each type used as a solution
  • Method Details

    • calculateCoins

      public void calculateCoins(double amount)
      Calculates the coins to be used to give a specific amount of money This method has a good complexity O(n)
      Parameters:
      amount - Amount of money that the needs to be given