A greedy algorithm makes locally optimal choices at each step in the hope of reaching a globally optimal solution. It works well when the problem has properties of optimal substructure and a greedy choice leads to an optimal solution. Huffman coding is an example of where a greedy approach succeeds - it assigns variable length codes to symbols based on frequency, with more common symbols getting shorter codes, in a way that minimizes the overall code length.