Answers for "All greedy algorithms follow a basic structure"

0

All greedy algorithms follow a basic structure

getOptimal(Item, arr[], int n)
  1) Initialize empty result : result = {}  
  2) While (All items are not considered)

      // We make a greedy choice to select
      // an item.
      i = SelectAnItem() 

      // If i is feasible, add i to the 
      // result
      if (feasible(i))
        result = result U i 
  3) return result
Posted by: Guest on May-31-2021

Code answers related to "All greedy algorithms follow a basic structure"

Browse Popular Code Answers by Language