Dynamic programming is used for sequence alignment and other bioinformatics tasks. It works by breaking problems down into smaller subproblems. Needleman-Wunsch introduced an algorithm for global sequence alignment using dynamic programming that maximizes matches between sequences. The algorithm involves initializing a matrix, filling it using scoring schemes, and backtracking to trace alignments. Local alignment follows a similar approach but replaces negative values in the matrix with zeros to restrict alignments.