# Difference between Brute Force and Dynamic Programming

• Last Updated : 05 Jul, 2022

Brute Force:

• It gives a solution to a problem by using the most straightforward method. However, it is typically not a very optimal solution or one that is flexible for future changes, but it gets the job done.
• The proverbial brute force programming example is trying all optimal solutions for reaching the final answer.
• Brute force programming tests every possible routing combination; whereas other mathematical algorithms obtain the results more quickly when the number of test cases is large.
• Brute force techniques are not generally used in the industrial field because they are not optimal in terms of space and time and slow downs the overall product or software.

Dynamic Programming:

• The dynamic programming approach is similar to divide and conquer in breaking down the problem into smaller and yet smaller possible sub-problems. In simple words, dynamic programming is an optimization over simple recursion.
• But unlike divide and conquer, these sub-problems are not solved independently.
• Rather, the results of these smaller sub-problems are remembered and used for similarity or overlapping.

Different ways of using Dynamic Programming:

• Top-Down: Start solving the given problem by breaking it down. If we see that the problem has been solved already, then just return the saved answer. If it has not been solved, solve it and save the answer. This approach is also known as Memoization.
• Bottom-Up: Analyze the problem and see the order in which the sub-problems are solved and start solving from the trivial subproblem, up to the given problem. In this process, it is guaranteed that the subproblems are solved before solving the problem. This approach is also known as Tabulation.

Difference between Brute Force and Dynamic Programming: The difference between these two approaches is mentioned clearly in the following table.

My Personal Notes arrow_drop_up