A greedy algorithm is an algorithm used in solving optimization problems. Greedy algorithms select the best result at each iteration. The global optimum is obtained by repeatedly selecting the local optimum.