105

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?

gnat
  • 20,543
  • 29
  • 115
  • 306
Vamsi Emani
  • 1,745

15 Answers15

131

One important point about data structures is that they are universal and timeless, at least for practical purposes. Anyone who's been a developer in the last 30 years should know basic data structures like single/double linked lists, binary trees or graphs. If you ask two developers about them, you can compare the developers' knowledge by their answers. This can hardly be said for frameworks or even languages: If you ask two developers about Rails, and one knows a lot more than the other, what does that tell you, really? As you say in the question, a smart developer can learn a new framework quickly enough, so testing their current knowledge doesn't make much sense.

Does, Not having knowledge in Data Structures really effect one's career in programming?

Yes. Definitely. Unless you want to spend all your life writing CRUD applications.

Or is the knowledge in this subject really a sufficient basis to differentiate a good and a bad programmer?

No, it's not sufficient. But there are few things you can ask in a job interview that are sufficient. And I'd say algorithms knowledge is one of the better indicators, at least for people fresh out of school, where you can't ask about work experiences.

nikie
  • 6,333
119

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.

Vamsi Emani
  • 1,745
Eric Lippert
  • 46,558
44

I am a quick learner and I can learn new frameworks, APIs or even programming languages within considerably short amount of time.

Not to sound too harsh, but any half-decent developer will be able to pick up a new language or framework in a relatively short period of time.

Data structures are universal, they are a fundamental building block of computer science -- a red-black tree is basically the same, whether it's implemented in Java, Python, PHP or whatever. So rather than testing specific languages, or specific frameworks, an employer (at least, an employer looking for stand-out developers) will test whether you know the fundamentals of computer science, rather than just whatever flavour-of-the-month they're currently using.

(at least, they should be testing the fundamentals in addition to whatever they're currently using... no point hiring a computer-science wizard if he's never written a line of code in his life)

Dean Harding
  • 19,911
30

Do you believe that F1 racers just drive fast cars? No, they understand the car they drive and they work with the mechanics/engineers to tune it. Of course, a normal driver just drives.

You can be a normal/average programmer that just writes code. You don't understand what's behind. You get things done. That's all, see you next day.

But many companies look for F1 developers. People that will develop knowing what is behind their code. People that will also help the company to build something better.

It's quite good to know data structures not only because you will use them in a "pre cooked" form a lot. It's also good because you will create something that derives from their idea.

graffic
  • 150
16

In my class on data structures, the very first thing the professor said was: This class is not about being able to search really fast. We then spent half a year finding the best possible data structures and algorithms to search really fast.

Still, he remained right. Being able to analyse data structures, apply the right data structure to a given problem or even come up with new data structures requires many qualities of an engineer:

  • Finding abstractions to model a concrete problem
  • Being able to decompose problems
  • Being able to reason logically/formally
  • Creativity
  • etc.

When Amazon and Microsoft hire people, they don't ask questions on data structures because they hope to invent the next quicksort. They want to make sure they hire someone with the above-mentioned qualities.

Of course it's possible to have a large set of these qualities and still suck at data structures. But then, if that's the case, it won't take you long to become an expert in data structures.


That being said, there is still the problem that ArrayList just doens't quite scale. When systems get large, better adapted solutions are required to perform the job. And without a good grasp of data structures, you won't be able to find and compose structures and algorithms which scale at large in your concrete scenario.

blubb
  • 2,774
12

In generally algorithms and data structures is regarded as two of the most "hard core" topics in programming. This is because there's a huge body of work and research regarding them in computer science. They also attract the typical "left-lobe"-programmers that like things like math and science (which is a whole lot of programmers)

That being said, knowledge of these might affect your career in terms of interviewing, especially if you interview at engineering-oriented workplaces like google. Other companies might now however care about that aspect at all.

In my experience algorithm/data structure demands can sometimes come across as "programmer elitism" where alpha geeks are jockeying to show who's the smartest. Its always good to know what's out there, but there are great many different programming jobs where you never will need to know how to use a red/black tree or code a boyer-moore search.

I'd recommend learning more about the topics if you find them interesting and have some personal project where you can tinker with them, otherwise you can probably get by without them for now

PS. Profiency with rudimentary data structures (linked lists, dictionaries, hashtables etc) should be a mandatory knowledge for any programmer DS.

Homde
  • 11,114
7

So really why all this emphasis on Data Structures?

Two reasons.

For one thing, it shows you can think about the problem in abstract terms, rather than in terms of a specific programming language. Do you know why a hash table may be a better or worse choice than a red-black tree in a given situation, regardless of the underlying implementation?

For another, there are a scary number of people out there interviewing for jobs who simply lie about their experience and have very little if any programming ability; data structures questions are a quick way of weeding these people out.

John Bode
  • 11,004
  • 1
  • 33
  • 44
5

They are fundamental, but also, what would you quiz graduates on? They may or may not have experience outside of their course work. Their course may have covered Microsoft technologies more than say Java, or vice versa. Data structrues are common ground.

Ian
  • 5,452
4

Often times the best code avoids reinventing low level data structures. This is especially true in high level languages. I have noticed a trend towards low level data structure questions even in CRUD jobs. YMMV, but it seems the emphasis on hacker scientist expertise has overshadowed the other skills that make a great developer:

  • project/time management: being able to keep up with the real world that is driven by business, not a new linked list that operates 1% faster.
  • a minimum amount of social skills: a developer that is arrogant and cannot get along is nothing but an anchor.
  • the ability to learn new things quickly and continuously: data structures hardly change over the years...but everything else does. Data structures are great fundamentals and every developer should know them pretty well, but an accountant does not get tested on their long division skills when they go in for an interview. Great developers are the type of people who can figure out new things and like it.

Data structures are great. Data structures are important. Every programmer should have an understanding of them. However, we have become obsessed with pushing these fundamentals outside of their place. It is not ALL about data structures, and in 99% of cases there is no need to ask questions beyond the basics of data structures. If you are interviewing an accountant, sure ask them what 81 divided by 9 is, but if you keep asking "What's the cube root of 98425454242412 * 4512324?...without a calculator!" then you will be frightening a good percentage of the reasonable, smart, talented, and agreeable people you could have had. Ask if they can build a basic relational data model, ask if they can use the enhanced array structures provided by the relevant framework, and ask if they can explain when a binary search is faster than flat search, but there is not much point going too far beyond that. If they can do those things, then start looking for the nicest, most professional, most creative one of the bunch.

I love Joel's writing, but I think his "Java Schools" thing is dead wrong. There are plenty of things that can prove someone is smart beyond mastering C++. Think about it, you can talk to someone for 10 minutes, without asking them about pointer arithmatic, and get a pretty good idea of whether or not they are the type who can get things done and figure stuff out. We don't need to be like this:

Interviewer: "Tell me about your accomplishments."

Coder: "In my last position I was the sole developer for a custom ERP system for a billion dollar financial firm. We delivered months ahead of schedule, and the system has been in production for the past 3 years."

Interviewer: "Let me clarify. Tell me about your programming accomplishments"

Coder: "Umm..."

Interviewer: "For example, have you ever made your own linked list?"

Coder: "...[walking out]"

4

Being a good programmer is not about being able to learn languages and frameworks. It is about being able to build solutions to complex problems. For these solutions to be efficient and reliable will almost always rely on good algorithms and appropriate use of data structures. Knowing the data structures exist is not enough. You need to understand the data structures will enough to use the right one for the problem. Lists and maps offer some valuable features, but they come with costs, and using the wrong one can significantly undermine the performance of your software.

A good interviewer knows this and is trying to determine if you can be valuable to his team or company. The language(s) you will be using 2 years from now may be very different, but the need for effective algorithms and data structures will not change.

cdkMoose
  • 1,785
2

Data structures, time complexity, memory manipulation, and pointers are all fundamentals that someone who calls themselves a Computer Scientist should innately know. Any code monkey can learn a language and learn how to use it, but where CS professionals and students should set themselves apart is knowing not just how to use a linked list or a hash map, but WHY.

The WHY is what really sets us all apart from the basic script kiddie, code monkey, and grunt of the computing world. WHY use a hash table instead of a linked list, WHY should my hash table be at a cluster density of roughly .6-.8, WHY should I use a circularly linked list here instead of a doubly linked list. WHY should my code be running at efficiency 'x' in the worst case and 'y' in the average case.

These basic data structures and knowledge of not just the HOW they are used (the how should be in every programmers repritoire anyway) but the language agnostic WHY they are used, which tends to be more of what they're looking for in these cases.

Many places will make you write the code in a language that you're firmiliar with, but that's more of a generality, seeing as C is really not the langua franca of the programming world anymore, and structuring pseudo code can be a mishmash and all over the place and, in most cases with pseudo code/p&p code not really being taught, down right impossible to deal with.

0

Data structures are the fundamental bedrock of all programs. You don't necessarily need to have a deep understanding of them, but you absolutely must know how they work.

Why? Because all of your code interacts with and manipulates data. If the data set cannot be stored in a structure, then it cannot be used. Data is like the building materials of a house. Until you put it together into a structure, you just have a useless pile of boards.

Once you have decided on how to think about and define your data set, then you can start using it to do things, the classic algorithm part of the duo. Every single program you write uses a data structure, though in many cases this structure is so simplistic as to almost not exist. A few variables for state data and we are done!

Once you move beyond trivial programs, almost everything requires a data structure. Which would you prefer, a professional architect who designs your skyscraper with best practices and math, or uncle joe bob who immediately starts building?

-2

To build on what @Pelshoff says, it is to show that you know what you're doing. If you use a LinkedList for everything, that may show you don't know what you're doing or you don't care to stop and think about the problem. On top of that, at least the data structures course I took covered, basic, complexity theory of those data structures which, when dealing with large data sets is very important. That would be why companies like Amazon or Microsoft would do such a thing.

I must say, before I took a data structure class I thought that they weren't important but at least being able to recongnize when a linked list (or ArrayList) isn't practical or what the draw backs of them are is important.

Jetti
  • 5,183
-2

Whether you write good code or not is a subjective statement. It's important to know that functional code does not always make good code.

That said, data structures are important because they are like the behind-the-scenes workers that you, as the programmer, are directing. It's true that you can call methods on a structure without really understanding what it's doing and you can utilize a structure without really getting how the data is stored, but knowing these details will better prepare you to understand when it is appropriate to use one structure over another.

Knowing, for example, that you can traverse in both directions through a doubly-linked list and only forwards through a singly linked list can help you determine which structure is important when storing data. You can make an even more education decision by knowing that a singly linked list can potentially have lower overhead in terms of memory consumption (since it doesn't contain pointers to previous elements) so, if you only need to iterate forward through a list, you can save some memory by using an appropriate structure.

These are just small examples and, ultimately, if you're feel you're doing well in your career without intimate knowledge of data structures then maybe you don't need to learn more. Understanding what's going on under the hood, though, can really help turn functional code into good code.

Jason
  • 101
-3

Data structures are building blocks of many things you want to do. If you know the uses for each data structure, its weaknesses and strong points then you can easily solve problems.

For example, we had a requirement to manage thousands of objects. Every once in a while we need to update an object's timestamp according to its ID. Every once in a while we needed to remove the objects that were not updated for more than X minutes.

If you know your data structures you can easily define the problem, and it is also very easy to come up with a solution. When a programmer that don't know enough data structures tried to come up with a solution, his solution was awkward. He was like you - smart, code programmer, able to learn frameworks quickly. But without a knowledge in data structures he had to invent the wheel by himself. More then that - he had hard time understanding simpler solutions since they were based on data structures he did not understand such as red-black trees (your old TreeMap in Java).

So, I'd say that the important thing is to know how and when to use each data structure without having to think about it. But I don't think there is any way of achieving that without actually understanding how they work.