Ask HN: How to learn algorithms and become a good programmer?
Hi HN'ers,
I am from a non-CS background. I find myself able to make stuff work and resolve issues in case any pop up, but i do not find myself writing the most optimized code.
How do i learn algorithms ? The problem is that the suggestions posted in various posts in HN are pretty intimidating to start. Is there a beginner friendly book or a youtube lecture that de-mystifies and simplifies learning algorithms ?
I mailed a few people whom i admire if they could provide guidance and / or mentor me, but haven't found help. IRC channels are intimidating too.
I would be grateful to the community for any help.
17 comments
[ 3.4 ms ] story [ 38.1 ms ] threadMIT OCW's Intro to Computer Science and Programming (in Python) covers a lot of ground related to programming (more than just Algos), but it covers some essential sorting algorithms and eventually gets into dynamic programming. I don't think anything much simpler than this would be worth your time (not to say this is the best), but the readings themselves (especially those from wikipedia) can actually be a little dense: http://ocw.mit.edu/courses/electrical-engineering-and-comput...
MIT OCW also has a full course on algorithms.
it may work to start with just one area, an area that is close to something you already are making or solving, and then, literally, in searching for algorithms for that pick the shortest one and solve a small implementation of it.
in finding a reference implementation i found the following helpful :
-- pick code in the same language you will be writing your version in.
-- if you can, find and read the original paper ( try searching google scholar ) describing the algorithm, these are often clearly written and explain the motivating situations that led to the way the algorithm was constructed.
finally some example short algorithms from a few areas and favorites of mine :
string processing :
-- LZW algorithm
-- longest common subsequence algorithm
tree graph processing :
-- post order depth first search
list processing :
-- group elements in an array into sub arrays of length k
integer processing :
-- change of radix algorithm ( change a mumber from the given base ( 10 ) to base 2 ( or even to other bases as well ) )
most of all, just work your way through step by step, like the algorithms your are making.
The above books are quite apt for beginners. You should expect to struggle a little but you must persevere anyway. I remember struggling with sorting and matrix multiplication algorithms when I learned it the first time in school. Do not mistake your unfamiliarity with the subject for its inherent difficulty! Once you write a few sample programs and see how the algorithms play out, you'll get the hang of it.
https://projecteuler.net
Remember that "making stuff work", aka prototyping, is incredibly important, and in fact an extremely desirable skill: in so many situations, it can be impossible to see the forest for the trees when building a new idea or architecture, and the design is still on paper; things frequently need to be built out into working first drafts for edge cases or gotchas to become apparent. Often, the result is that everyone might need to go back to the drawing board and start from scratch, so rapid turnaround is essential.
Going beyond the basics in any domain is a categorical form of specialization, and specialization in any context tends to require a lot of investment, and the return it gives predominantly leans toward inflexibility and a narrow field of application.
When tackling arbitrary, ambiguous problems, the statistical likelihood your specialized knowledge will come in handy is, on average, going to be quite low, unless you're in an academic environment that focuses on your specialty.
So don't shun the skillset you already have in "making things work." :D
By all means dive into algorithms - just remember the info will likely stay in if you do so at a slow, non-anxious pace and keep your experiences positive ^^