parent::Algorithms

Greedy means what is profitable to us. In Computer Science,choosing the best solution at the moment and then moving forward to achieve the optimal solution is being greedy.

A two step process

  1. Choose the solution at the moment according to certain condition.
  2. If it is a feasible solution add solution to solution set,else reject the solution and never use it again. Repeat step 1,2 until optimal solution is reached or condition no longer satisfies.

Example

  • Form two digit greatest number using the given digits.
    • Greatest digits are picked greedily to form largest two digit number.
  • Use the least amount of notes and form the given amount.
    • Greater amount notes are picked to form the given amount first.

Disadvantage

It is always not completely possible that greedy would lead to optimal solution.

References::

Tags:: algorithms computer-science

Back-links::