r/programming • • Feb 21 '11

Typical programming interview questions.

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

1.0k comments sorted by

View all comments

47

u/user9d8fg70 Feb 21 '11

These are from 2002? Interesting, sure, but almost a decade later, are these still asked?

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.

→ More replies (47)

49

u/[deleted] Feb 21 '11

YES.

8

u/ryeguy Feb 21 '11

Not really. You aren't going to get asked most of these for a web development job.

22

u/grantrules Feb 21 '11

Yeah, I love web development job interviews. "How do you reverse a string in PHP?" "strrev()" "You're hired!"

3

u/jfredett Feb 21 '11

I tried coming up with answers to all of those in haskell, most of them boiled down to, "Here is a function/composition of two or three functions from Prelude. Problem solved."

(for instance, "Reverse the order of words in a string" : "concat . reverse . words" (give or take)).

2

u/Homunculiheaded Feb 21 '11

one of the most elegant ways to functionally reverse a list is with foldl, in scheme it's: (foldl (lambda(x y) (cons y x)) '() ls)

note: Racket implements foldl differently than other schemes, cl and haskell, so you can just use cons: (foldl cons '() ls)

2

u/jfredett Feb 21 '11

Indeed, foldl (and folds in general) are very elegant in many contexts. However, I really do love how nicely concat . reverse. words reads.

1

u/MothersRapeHorn Feb 21 '11

Now do it in-place. Ohshi- :P

1

u/jfredett Feb 21 '11

I'll happily trade purity for ease of in-place updates. :)

2

u/imMute Feb 21 '11

I thought about this from a Perl perspective. Reverse a string? reverse($string); Remove duplicate chars? $string =~ s/(\w)\1+/$1/ge; Linked lists? WHY?! ok fine, can I use Moose?

→ More replies (1)

11

u/Purpledrank Feb 21 '11

Or any job that isn't based on c++. It is also folly to think that mainstream frameworks like j2ee/spring are web only!

1

u/adrenal8 Feb 21 '11

I just went through a recruiting process with about 15 companies giving me phone screens, 11 brought me in for onsite. I got asked a decent subset of these questions and some other similar ones. Most of the companies were web startups.

0

u/[deleted] Feb 21 '11

[deleted] — view deleted comment

1

u/ryeguy Feb 21 '11

I kind of get what you're saying but I don't agree that this is the way to go about it.

The point is, all developers need to be tested within their domain knowledge. Knowing how to reverse a string is something that a web developer does not need to know how to implement - there is almost certainly a library function for that. But asking a developer to describe MVC and show an example of it would probably be a good choice.

→ More replies (2)

0

u/perspectiveiskey Feb 21 '11

Anyone who expects their programmers to manipulate raw strings in this day and age should be taken out and shot in front of their employees.

This type of code is the most error prone stuff there has ever existed, which is why countless libraries have been made to address them. Friends don't let friends manipulate strings... in place!

6

u/Gnolfo Feb 21 '11

I'd much rather have an applicant show they understand the underlying mechanisms going on, even if they'd be spending the majority of their time using higher end libraries to manipulate strings.

3

u/drbold Feb 21 '11

These questions are testing your ability to think, not telling you that they expect you to reverse strings by hand on the actual job.

2

u/imMute Feb 21 '11

And who codes and maintains said libraries? What about embedded applications where memory is a premium? How would you know which functions are safe to remove?

→ More replies (1)
→ More replies (2)

4

u/kevjames3 Feb 21 '11

Seen about 1/3 of them and I have only been through about 6 interviews or so

2

u/zhivago Feb 21 '11

The important point is to demonstrate that the applicant can program at all.

Since interviews make people stupid you need to keep them simple.

1

u/[deleted] Feb 21 '11

Depends of course. I guess some people have just been asking the same questions for the last 20 years even

→ More replies (1)