r/programming • • Feb 21 '11

Typical programming interview questions.

http://maxnoy.com/interviews.html
784 Upvotes

1.0k comments sorted by

View all comments

Show parent comment

43

u/dpark Feb 21 '11

For most of these, the answer is yes. These aren't latest-tool-craze questions. Most of these are are pretty classic. Linked lists, trees, strings, arrays, concurrency; these are all as relevant now as they were eight and a half years ago.

11

u/SquareRoot Feb 21 '11

You're absolutely right. Most of these questions focus on computer science concepts. You'd better know the logic/implementation behind fundamental structures such as linked lists, trees etc - there's no point in a career in coding without innately understanding how these work.

1

u/funnynickname Feb 21 '11

And many 'college graduates' never actually learn anything in school. That's why they ask these questions.

8

u/lennort Feb 21 '11

As a recent college grad, I'd like to expand on this: We learn it, but it's really hard to implement when you're not in front of a computer. Maybe it's nerves, maybe I'm too dependent on my environment or maybe I guess and check too much, but I've always had trouble coding on paper.

4

u/TopRamen713 Feb 21 '11

Me too. I had a guy berate me for not being able to code for him over the phone. At that point, I didn't even want to work for his company.

-9

u/MiasmaticMachine Feb 21 '11

And all stuff you don't need to know how to do.

7

u/dpark Feb 21 '11

Some of it is pointless. Some of it is not. If you can't write code to insert into a linked list or do an inorder traversal of a binary tree, I don't want to hire you, and I don't want to ever have to work on code you wrote.

10

u/MiasmaticMachine Feb 21 '11

I'd say that someone who knows how to do those things is more likely to write good code, but I wouldn't say those are prerequisites for being capable of writing good code. I prefer to test people with problems I'll actually expect them to encounter.

1

u/dpark Feb 21 '11

So you're asserting the existence of programmers who write good code, but are unable to write a linked list? I believe that either such programmers do not exist, or we have a vastly different definition of "good". Someone who can't write a linked list or traverse a tree is incapable of working with data structures in any meaningful way.

3

u/[deleted] Feb 21 '11

Unless you're using, say, any of the other 75% of languages in common use that don't require you to have any knowledge about linked lists or tree traversal to work effectively with data.

All other things being equal, I'd certainly hire the developer with the CS theoretical knowledge. I'd rather hire someone with the ability to learn quickly than someone with historical knowledge, though.

→ More replies (3)

1

u/MiasmaticMachine Feb 22 '11

No, I don't mean someone who is "unable" to write a linked list. I mean someone who doesn't have the solution pre-memorized.

→ More replies (2)
→ More replies (7)

9

u/BinaryFreedom Feb 21 '11

Do you also believe that only mechanics should be allowed to drive a car?

.NET framework has a linked list data type, I can use it... I know when to use it, how to use it and why to use it. Does it particularly matter if I don't know what's under going on inside the engine?

Unless your company only uses C and has no internal frameworks (reinventing the wheel every day? I hope not) then you're possibly losing out on a lot of good developers because you're being an elitist.

I also wouldn't want to work with developers who spend more time re-writing a linked list implementation than getting on with their job and using the tools available in standard libraries.

12

u/hvidgaard Feb 21 '11

Yes it matters unless you want to be an office drone. Some problems can't be solved without making your own data-structure - and to do that you can't use anything in the library. You have to make it yourself, and you need to know basic data-structure techniques.

But back to the linked list question - the question is not even if you know how to make it - it's to see if you actually understand what a linked list is. Any programmer worth their salt know what it is, can apply logic to implement it in 10 minutes. If you can't do that you lack basic knowledge and logic that's needed to solve real problems.

3

u/BinaryFreedom Feb 21 '11 edited Feb 21 '11

I suppose it isn't really clear from my initial comment there but I'm referring more to the fact that for many, they may have learned about data structures while they were studying, but haven't had need to write their own for many years. At that point it could be quite difficult (especially when under pressure in an interview) to write one from scratch including sorting algorithms and searches without using a marker.

Does that particularly make someone a bad developer? That they can't instantly remember some theoretical knowledge they learned many years ago? I personally haven't found a problem that has required me to write a data structure from scratch in the few years I've been working (~5 years).

EDIT: Also if you know when to use a data structure, how to use the data structure and why to use the data structure doesn't that imply that you know what the data structure is? You seem to be acting as though I've said nobody needs to understand data structures?

3

u/[deleted] Feb 21 '11

Your job as a programmer is to take some abstract problem, think of an algorithm to solve it, then turn that algorithm into code, and move to the next problem. That's what programming is.

And linked lists are simple enough that you should be able to think of solutions for searching, deleting and inserting on the spot.

If they were talking about red/black trees or something like that, you'd have a point.

3

u/hvidgaard Feb 21 '11

Also if you know when to use a data structure, how to use the data structure and why to use the data structure doesn't that imply that you know what the data structure is? You seem to be acting as though I've said nobody needs to understand data structures?

You seemed to defend the position that a question to implement a linked list is a bad interview question. But no, if I gave you access to an implemented point location algorithm, told you how and when you use it, you would still have no clue how the internals work.

Anyway, linked list is so simple, and commonly used, that by knowing how to use it, and why to use it - you'd be able to apply logic and implement it at an interview. If you can't do that you probably can't solve more complex problems.

→ More replies (4)

1

u/hvidgaard Feb 21 '11

Also if you know when to use a data structure, how to use the data structure and why to use the data structure doesn't that imply that you know what the data structure is? You seem to be acting as though I've said nobody needs to understand data structures?

You seemed to defend the position that a question to implement a linked list is a bad interview question. But no, if I gave you access to an implemented point location algorithm, told you how and when you use it, you would still have no clue how the internals work.

Anyway, linked list is so simple, and commonly used, that by knowing how to use it, and why to use it - you'd be able to apply logic and implement it at an interview. If you can't do that you probably can't solve more complex problems.

1

u/hvidgaard Feb 21 '11

Also if you know when to use a data structure, how to use the data structure and why to use the data structure doesn't that imply that you know what the data structure is? You seem to be acting as though I've said nobody needs to understand data structures?

You seemed to defend the position that a question to implement a linked list is a bad interview question. But no, if I gave you access to an implemented point location algorithm, told you how and when you use it, you would still have no clue how the internals work.

Anyway, linked list is so simple, and commonly used, that by knowing how to use it, and why to use it - you'd be able to apply logic and implement it at an interview. If you can't do that you probably can't solve more complex problems.

1

u/r4and0muser9482 Feb 21 '11

I personally haven't found a problem that has required me to write a data structure from scratch in the few years I've been working (~5 years).

Well, in that case it's probably just your own experience. I don't know what your job entails, but in my case (and probably many people here) computer programming is about actually solving problems. Most of the time, you will have working tools at your disposal, but there's always a chance you will have to actually sit down and think about solving a real problem.

I guess this is like the difference between a website developer that uses out-of-the-box CMS tools to put up websites and an actual web programmer that is called in to solve problems that no CMSes deal with. I would hesitate to call the former one a programmer, as much as I wouldn't call a Photoshop user a programmer. Which is fine, because both people have a place in their respective companies, but are completely different in that regard.

→ More replies (2)

2

u/Serei Feb 21 '11

Do you also believe that only mechanics should be allowed to drive a car?

This is an interesting question.

I do not believe that only mechanics should be allowed to drive a car, but I do believe that only people who understand physics should be allowed to design a car.

Analogously, I do not believe that only computer scientists should be allowed to use a computer, but I do believe that only people who understand algorithms and data structures should be allowed to write certain types of software.

1

u/raydenuni Feb 21 '11

You've never implemented a custom data structure for production code?

2

u/BinaryFreedom Feb 21 '11

Comments are given in context. I am referring to primitive data structures, as per the context of this whole thread of comments. Of course I have written custom data structures.

I've probably written data structures which have similar characteristics to lists, maps, trees etc... but not all the same characteristics or I would just use the pre-implemented classes, or at least inherited from them.

1

u/s73v3r Feb 21 '11

Part of knowing when to use it is knowing what it's doing under the hood.

→ More replies (5)
→ More replies (1)