What are some ways to approach designing an algorithm for a new problem?
What are some ways to approach designing an algorithm for a new problem?
1. Frame your problem in terms of another, more general problem to use an already existing algorithm.
2. Start with a Brute Force application to give yourself a base. Then optimize it.
3. Divide and Conquer - a way of dealing with a large problem by breaking it down into bits and pieces and working your way up towards the solution.
Instead of seeing the whole problem as a single, huge and complex task you divide the problem in relatively smaller problems that are easier to understand and deal with.
You solve smaller problems and aggregate the solution until you are left with the solution only. At each step the problem at hand shrinks and the solution gets mature until you have the final correct solution.
Solving the smaller task and applying the same solution repetitively ( or often times recursively) to other chunks give you the result in less time.