Getting Good At Algorithms: Progress Report #4
On contraire to what I wrote previously, being good at algorithms is not just a factor of knowing a lot of good algorithms and just applying them to the right situation. Studying existing algorithms give you ample examples for developing ones’ intuition for coming up with innovative solutions to new problems.
These techniques that have been applied in the design of these algorithms proivde food for thought - a toolset of possible assumptions that can be applied to the problems that we encounter.
Example: Finding the median
The first impulse of everyone who wants to solve a algorithmic problem is - How do I find the right solution? But this is an example where we start off with select a potentiall wrong one and arrive at the right one and end up benefiting in the end.
It is easy to find the median of a set of numbers. You just have to sort the numbers and get the number which is at the middle. But that has time complexity of nlog n. Can we do better? Yes.
If we randomly assume an answer as a starting point and leave it probability.