Why are data structures so important in interviews?
I must confess that I was not so strong in data structures when I graduated out of college. Throughout the campus placements during my graduation, I've witnessed that most of the biggie tech companies like Amazon, Microsoft etc focused mainly on data structures. It appears as if data structures is the only thing that they expect from a graduate.
To be honest, I felt bad about that. I write good code. I follow standard design patterns of coding, I do use data structures but at the superficial level as in Java exposed APIs like ArrayList, LinkedList etc. But the companies usually focused on the intricate aspects of Data Structures like pointer based memory manipulation and time complexities.
Probably because of my Java background, back then, I understood code efficiency and logic only when talked in terms of Object Oriented Programming like objects, instances, etc but I never drilled down into the level of bits and bytes. I did not want people to look down upon me for this knowledge deficit of mine in Data Structures.
So really why all this emphasis on Data Structures?
I don't really get your question. You say "I write good code" -- how can data structures be not part of good code. And, I doubt any sincere interviewer would be excessively obsessed with them.
@greengit: There's a difference between implementing a hash map, and using its API. What I would value in an interview is if they'd describe an application for me, then asked me to build up the central data structures, and explain my choices.
@Jurily - To understand when to use a container library, it helps to have some knowledge of how the underlying data structure works. It's hard to accept that you know about efficiency of code if you don't know the time and space complexities of the libraries you are using - just because it works well on small test datasets doesn't mean it'll scale well to larger datasets in the real world. IMO, understanding the time and space complexities is as much a part of understanding the API as knowing the class and method names - perhaps more so, as intellisense won't tell you the complexities.
@Veekay: Dont you feel Eric Lippert's answer is a more complete and detailed one than nikie's? Not being mean, just think Eric's answer is more useful (and again, detailed) in terms of understanding one of the biggest company's reasons for asking about data structures.
Its simple. If you do not know how a data structure works then how can anyone expect to use it? If the companies you want to work for focus on data structures, the simple solution, learn how they work
A good data structure give clean, simple code. A bad data structure give complex code. It is important to get right.
I think he knows the basic concepts of data structures with some variants (ArrayList and LinkedList), but don't know the implementation details of each one. I think that knowing the basics is enough for a lot of jobs.
It sounds like you might be a little scared of complex data structures. Do the coursera.org Algorithms course in your own time and I promise you it is easier than it first appears. I am a bit slow and I can follow it - you sound much smarter ;)
This question is off-topic but is interesting and provides value. There is now a meta question for cleaning up this old question and its answers: **Let's clean up the Data Structures for Interviews question**.
most of the biggie tech companies like Microsoft focus mainly on data structures. It appears as if data structures is the only thing that they expect from a graduate.
No, there's more. For example, we also expect that you be a quick learner who can learn new frameworks, APIs or even programming languages within a short amount of time. That's a bare minimum bar. Someone who takes a long time to learn a new framework, API or language will not be a successful developer on most teams at Microsoft.
And of course there are many more aspects that we focus on in interviews other than just raw knowledge of data structures. Ability to deal with ambiguous specifications, for example, or ability to recognize coding patterns that produce insecure code, or a dozen other things. But ability to understand data structures certainly is a very big one.
It is particularly the case that interviews are biased towards testing knowledge of data structures for recent CS graduates. Recent graduates, most of whom do not have a lot of real-world experience, are not expected to be good at the same sorts of things that someone with fifteen years of industry experience would be good at.
I must confess that I was not so strong in data structures
It's good that you know that about yourself. If you're unable or unwilling to change that about yourself then my recommendation is that you don't apply for a job that requires facility with data structures.
there is this general perspective that a good programmer is necessarily a one with good knowledge about data structures.
It's tautological that a good programmer is a programmer who is good at building the sorts of programs that need to be built. Lots of programmers work on tasks that do not require deep knowledge of data structures. Some of them work on tasks that require a deep knowledge of user interface design, for example. Or database normalization. Or whatever. Those people can still be "good programmers" in their domains.
why all this emphasis on Data Structures?
I ask interview questions about data structures because on my team the developers design, implement and manipulate complex data structures all day every day. Yesterday we had four hours of meetings in which a half-dozen developers argued the pros and cons of adding single Boolean field to a particular tree node. There is probably no skill on my team more important than ability to understand data structures at a deep level. It would be foolish to not ask interview questions about it, since that's what we do.
Does not having knowledge in Data Structures really affect one's career in programming?
Well it certainly will prevent you from getting a job on my team. But like I said before, programming is a huge field. There are lots of kinds of computer programming that don't require knowledge of data structures.
is the knowledge in this subject really a sufficient basis to differentiate a good and a bad programmer?
No. But it is almost always sufficient to detect developers who are unlikely to be successful at Microsoft. Since that is what I am primarily interested in detecting, knowledge of data structures is one of the factors I test for in interviews.
Thanks a tonne Eric! This is the least demotivating answer that I've got for my question. :-)
@EricLippert, thank you for this excellent answer. As a self-taught developer who has yet to be bitten by his lack of formal knowledge of data structures, do you recommend a book that could show me what I've been missing?
@Closure Cowboy: For the basics of data structures and algorithms, "Introduction to Algorithms" by Cormen, Leieserson and Rivest is the standard textbook. If you are interested in functional style data structures, Chris Okasaki's book is very good but quite advanced.