Implement dynamic programming algorithms