Ask HN: How can a self taught developer learn Computer Science fundamentals?
I'm applying to software engineering jobs right now and I have the following questions for the HN community:
1) How can I do better in technical interviews where they ask me CS questions? What have other people done in this situation?
2) Are CS fundamentals really important in the real world? Does it depend on the position? What if you're a JavaScript engineer working with Backbone, browser performance, etc.
3) Recommended courses (online or offline) to learn CS?
Right now I'm reading Introduction to Algorithms by Cormen et al.
Example interview questions:
* Given an array of negative and positive numbers (eg -100..100), find groups of two that sum to zero. Now find groups of three. Now find all groups.
* Implement a function that takes an integer n, and returns the number of 1's in the binary representation of n.
* Implement a function that takes takes 3 (x,y) coordinates which define the vertices of a triangle, and a 4th (x,y) coordinate, as inputs. Return true if the 4th point falls inside the triangle defined by the first 3 points; false otherwise.
* Write an extract_word_series() function that takes a string and returns a 2d nested array where the inner arrays are a group of contiguous words. Assume you have an is_word() function.
* Write a function in Ruby to do a binary search of an array.
* Google interview topics: big O notation, sorting, hashtables, trees, graphs
17 comments
[ 1.9 ms ] story [ 59.2 ms ] thread1) How do you expect to do better when they ll ask you something that you don't have a clue what it is?? My answer is you CAN't
2) Recently i heard an exact same story. The guy was a realy passionate developer, NOT good BUT passionate. He went on a public college and got his deegree in 4 years. He's now a professional developer.
There is a nice maxim l really like. I think it's Japanese, not sure though. It says: "Theory without practice equals wasted time. Practice without theory equals wasted toil." So to answer your question it's VERY REALLY important. It certenly depend on your salary! Do you really want to be 50 yo and still writing Ruby? I really don't!
Reading all by your self stuff that students are tougt in third year on a college.. it's going to be a pain in the ass.
To sum up i really believe that you are still young and you can do a lot. Go find some good teacher, either online or in a college. Get a degree. Your eyes will be WIDE open then. Thing's you have never thought will outpouring in front of your eyes.
Best Regards, KB
2)Are they important? Yes and No. Will you use your knowledge ofdata structures and algorithms everyday? For most jobs the answer tends to be no. Will it help you overall be an efficient developer? Absolutely.
3) There are so many, Khan Academy and Coursera are quite good I think, give them a shot.
1) Practice. Glassdoor is an indispensable tool for this. For example, if you're interviewing at Facebook, you can basically compile a list of the algorithms that have been asked and practice that set, until you have it completely down. Rehearse in front of peers, friends, pets, inanimate objects, whatever. You can likely find a working solution to any of these problems on stack.
2) Yeah, they are pretty important, but probably not to the degree that they are emphasized in the interview process. For example, a common theme in algorithm problems is finding a solution which works within a certain time complexity (linear, log, etc). In practice this often reduces to the following situation: You are doing some calculation which involves a bunch of nested for-loops. Eliminate one of the inner for-loops.. or something to that effect. So yeah, it's important practically. It becomes more important when you're dealing with millions of records and terabytes of data, and an extra for-loop could mean that your program effectively runs a month longer than it should.
3. The only online course I took for CS stuff was a MIT open-courseware class on Algorithms. Additionally, I highly recommend the book "Algorithms" by Robert Sedgewick and Kevin Wayne.
So you already have enough to choose your job. Missing a CS theory question in an interview should not be the difference between pay-rent and no-pay-rent for you.
Therefore, the reason to learn deeper CS theory is because you WANT to learn it, because you find it interesting for its own sake, because you want to master your craft. That's good, that's pride. In that case, study some well-regarded algorithm/data structure books and other classics, do code katas (google it), maybe even go back to school and get an MIS degree.
I'd also recommend learning languages. C in particular is important, because it will teach you how memory is managed. If you've never had to manage it manually, there are a lot of things you don't understand. This doesn't mean I recommend manual memory management (geez, if ANYTHING invites automation, it's memory management!), but it's good to understand how and why.
Your most important asset right now is time. It looks like you have the desire, so all you need is time to read books and practice. And then practice some more. And then keep practicing.
I've enjoyed this website tremendously: http://codingforinterviews.com/
Every couple weeks you get an email packed with sample interview questions, advice, and practice problems. Go sign up for it. (I am not affiliated with it in any way, just a fan).
Also, for Javascript, one of the most useful/difficult topics I've struggled with is Regular Expressions. Take a look at http://regex.learncodethehardway.org/book/ if you haven't already.
How useful things are in "the real world" varies greatly. The consensus seems to be that a lot of people say they go through their whole careers without ever using any of the things you learn in CS (for example, you'll hear a lot of "I've not once ever had to implement quicksort"). I don't doubt that these people are correct, it seems pretty apparent that you can certainly have a go at being a developer without knowing all the fundamental theory.
Some people seem to take this as a point of pride, however; like knowing those things would be a drag and a waste of time. I find this attitude perplexing, although I'll admit that it might just be a flaw in my wiring.
I want to know EVERYTHING. Literally, I want to know everything. This can't happen, obviously (both for reasons around the limits of time, and also my intellectual failings), so I try and prioritize.
If you decide that you really do want to learn all the fundamental stuff, I'm sure people will suggest all sorts of ways that they've been able to do so. Pick and chose the things that people say that seem appropriate to your case, but obviously, everyone learns things differently, so don't expect there to be a good foolproof path you can take.
What I've been doing (and keep in mind, I'm an idiot, although I hope slightly less of one every day), is really a brute-force approach.
First, I looked at the curriculum at a bunch of well-regarded CS undergraduate programs (I picked MIT and Stanford, mostly because in addition to being pretty well-regarded, both have a lot of material online). I looked at what their early intro CS classes looked like, what books they used, what the lectures looked like, etc.
For books and topics which overlap between schools, that's an easy choice as to what materials to use (for instance, it seems like almost everyone uses CLRS for algorithms, so you can pick that one and at least feel comfort knowing you're in good company. I actually used CLRS in school, so this second time around I picked up Skiena's algorithms book ((mentioned effusively by tptacek on here a number of times)) and have been going through that.
If you literally just pick out the books from the undergrad classes at a couple of good CS schools and read them completely (and do all the exercises), you'll be a good part of the way there. That's not to say you get the same experience as being there (you don't), but presumably taking four years to go enroll in an undergrad program isn't on the table as an option, so you're making due the best you can.
And yes, the real knowledge will come from actually using the stuff you learn in the books, so the whole time, be writing programs ("ABC"...Always Be...Computing).
After the third or fourth "level" of classes, is usually the time in undergrad where you then start to specialize. After the core curriculum, you'll find that not everyone takes every class, you just have some number of classes from the "CS bucket" that you have to take, and you pick from it based on schedule and interest. Here is where you have an advantage over people actually in school, however. You don't also have to be taking philosophy (although maybe you should, again, in my case I want to know everything, of which philosophy is a definite subset), so you can spend as much time learning as many things as you want.
Want to learn about compilers? Read a book and build the projects. Graphics? Networking, Functional programming (assuming the intro books were predominantly imperative), whatever you want.
Basically, learn as much and from as many topics as you want to.
That won't help you in the short term ace programming job interview questions (and to be honest, I'm not sure if anything can really be that helpful as a short-term solution).
Again, I want to reiterate, you can have a long and successful career as a software developer doing none of these...
Prior to my first technical interview I spent tons of time studying algorithms and data structures. Looking back I feel that my time would have been better spent selecting several sample questions (such as the ones you included) and solving them on a whiteboard over and over again (and checking and improving them along the way).
For questions check out careercup.com, glassdoor.com, project euler, and the Cracking the Coding Interview book: http://www.amazon.com/Cracking-Coding-Interview-Programming-...
The more practice you have, the faster you will be able to: recognize what type of problem a particular question is, come to an initial solution, and improve upon that solution.
Feel free to reach out to me with any questions! (contact info in my profile)
Go to a good University.
That being said, the software industry has a bit of a fetish for giving these problems in interviews, even though they're rarely used in your job, and there's little evidence that performance on these problems is the best way to evaluate candidates.
If you want to be a smart-ass after the interview, study up on Bayes' Law, and lecture your interviewer about it. I.e., p(good programmer|pass interview puzzles) != p(pass interview puzzles|good programmer). If you hire someone because they did well on these problems, you later have data on how well they do at the company. However, you will lack data on how well someone does at the company if they don't do well on the problems (it could be they do just as well), so you have no evidence it's good at classifying candidates.
In particular, while I think interview problems are reasonably correlated with talent, I'm not convinced that they're a higher quality source of information than things like whiteboard exercises, real coding exercises, and code samples. It's also biased by things like recency (was your algorithms class last year?) and cramming (be sure to go through Cracking the Coding Interview exercises).
I suspect it's because only the largest companies could risk running two types of interviews, one with puzzles and one without, hiring equally from both, and then look at the data later. Even there, though they could absorb the hit, if they're wrong, they'll have made a bunch of low-quality hires...
Or just read CLRS. That is like the definite book of algorithms. I bet like ever CS student has that book.
http://www.youtube.com/watch?v=xlUFkMKSB3Y&list=PL0862D1A947...
Also check out their other CS videos.
http://nptel.iitm.ac.in/courses.php?disciplineId=106
Finally, put Youtube in HTML5 mode so you can increase the play speed if needed.