3 ms·
Ask HN: Know algorithms, or know how to implement them?
I'm playing around doing leetcode challenges for fun where I stumbled upon one which required quicksort. It struck me then that I've completely forgotten how to implement it (which I once did a couple of years ago at uni), I had to go to wikipedia and write it from pseudo code. All in all it took me about 30 min to solve.
This got me thinking; is this even an issue? Is there value in knowing algorithms like quicksort and Djikstra's by heart, as opposed to being confident that you're able to implement them given information on how to do it?
- bradwood 4y agoWhat's more important is knowing how to analyse/derive the big-O of each of the various algorithms in space and time, IMHO.
- rantallion 4y agoI'd agree with this but also add that it's important to know the benefits of each algorithm compared to others in the same class (i.e. when you'd use each sorting algorithm). It also helps to be able to adapt an algorithm when the vanilla version doesn't quite cover what you need. I don't think I've ever had to implement a well-known algorithm from scratch at work - I'd just use a library for that and spend my time focusing on business logic.