What is dynamic programming?

Sequence alignment methods often use something called a 'dynamic programming' algorithm. What is dynamic programming and how does it work?