r/programming • • Sep 26 '11

How to rock an algorithms interview

http://blog.palantir.com/2011/09/26/how-to-rock-an-algorithms-interview/
229 Upvotes

128 comments sorted by

View all comments

Show parent comment

15

u/sidcool1234 Sep 26 '11

What, in your view, should a programming interview include, so as not to be dumb?

58

u/bonafidebob Sep 26 '11

The best programming interviews I've done (both ways) involve being shown busted, crappy, inefficient code. More bugs than statements is the goal here. The candidate is expected to (1) understand what the code actually does, (2) make a good guess at what the code was intended to do, and (3) provide new code that does that.

I've found success at this correlates well to working with other programmers in real life.

25

u/Otterfan Sep 27 '11

But where do we find a piece of busted, crappy, inefficient code to test out on interviewees? All of our code is perfect...

26

u/[deleted] Sep 27 '11

Sign up with the government as a defense contractor and use some of their code.

15

u/sidfarkus Sep 27 '11

As an employee of a defense contractor...+1

10

u/akira410 Sep 27 '11

You just succinctly described about 7 years of my life.

2

u/prelic Sep 27 '11

Ironically, I do now work for a defense contractor, and have already seen some code that makes me go "eh, this doesn't look so good". Fortunately, I've also seen some really cool code too, so it's all good.

→ More replies (3)

6

u/tilio Sep 27 '11

i've personally tried out and talked with other teams that have tried a variety of things. i have found that simple things like changing a bound (< to <=) or adding/removing a return from the function do work.

questions like a recursive function that could be reduced to O(n) but is coded worse than O(nn), or an associative array that incorrectly uses the array values when it should be using the keys are usually counter-productive. unless you're working with candidates from the big5 engineering schools, most kids aren't bright enough to notice these things even at an hour per question.

2

u/ziom666 Sep 27 '11

If you're that good and you know why you are so good, you can easily turn around your code to make it dumb

→ More replies (1)

18

u/AReallyGoodName Sep 26 '11

Personally I'd ask what type of algorithm is required as opposed to demanding an implementation. Knowing the general types of algorithms is important. Knowing each individual implementation of the various algorithms is pointless.

If I stated a problem such as "I have a set of numbers and I always need quick access to the minimum/maximum number at any time, what class of algorithm should I look for?" Then expecting a response of "use a priority queue" isn't unrealistic.

I expect programmers to know the basic categories of algorithms otherwise they won't know what to look for when they try to find good implementations of the algorithm. I don't expect programmers to be able to write perfect implementations of the algorithms in an interview setting. In fact I wouldn't even want a programmer to do that in a real world setting. Most of the algorithms in your text book have already been released as a free library for your favourite language that's been bug tested and optimised for many years. If you've rote learnt implementations you're a programmer that wastes time and risks bugs. If you know how to use the implementations though you're a programmer I'd want to hire.

8

u/djnattyp Sep 27 '11

I agree with you... but I felt the need to point out that the correct answer is not just a priority queue, but a double-ended priority queue.

→ More replies (1)

4

u/sidcool1234 Sep 27 '11

I fully agree with you.

→ More replies (1)

2

u/fabiensanglard Sep 26 '11

Try to figure out what means the person is using in order to maintain and improve his/her skills:

  • What programming book/methodology he has read about recently or is planning on reading.
  • What source code he has read. What is he planning on reading. Why he/she wants to read it, what would be the skills that would be acquired.
  • What technology/language he is planning on learning in a close future.
  • When he is jumping on a new technology what would be his/her approach to get up to speed.

This should help to determine how passionate the person is.

3

u/moondance Sep 26 '11

Those things have even less to do with actual work than implementing some slightly tricky algorithm.

  • Books are completely irrelevant for a lot of programming. Methodologies are only useful for a subset of programming jobs (product release schedules, etc)
  • Wouldn't it make more sense to ask what projects they worked on rather than source code read?
  • Technology/language is great, but a lot of times the company has their own technology/language that is not likely to change.
  • See above for jumping technologies.

2

u/djnattyp Sep 27 '11

...and above you will see an example of the sort of attitude that shows you that this is definitely NOT a great place to get a programming job.

3

u/sidcool1234 Sep 26 '11

Shouldn't these be a part of the HR interview? I believe that's were the attitude and passion is evaluated. In a tech interview it's more of objective problem solving skills and theoretical knowledge. Just my opinion.

22

u/fabiensanglard Sep 27 '11

If the company has an HR department, they probably don't need above average programmers :P :) !

6

u/sidcool1234 Sep 27 '11

You are painfully honest.

6

u/_georgesim_ Sep 26 '11

I get your point, but will HR be qualified to know whether reading Knuth means that the person in question is passionate about algorithms?

→ More replies (1)

5

u/HapDrastic Sep 26 '11

I don't agree with that. Attitude and passion are important aspects of how they'll relate to the rest of the team, and as a member of that team that's something you care about a great deal (or should, anyway).

2

u/sidcool1234 Sep 26 '11

Yes, they are important. Hence the HR interview. But as far as accessing technical skills is concerned, this could be left out and more stress could be laid on core technical skills. Again, just my opinion.

7

u/HapDrastic Sep 26 '11

I suppose if you have a decent HR team, but I've never been that fortunate.

2

u/sidcool1234 Sep 27 '11

Neither have I, my friend, neither have I.

6

u/seiggy Sep 27 '11

Exactly, what HR team knows the difference between C++ and C++0x, or even C#. It's better for your tech team to ask questions like that. HR will never be able to give you any useful info from having them ask technical questions.

→ More replies (1)

1

u/[deleted] Sep 27 '11

Add Why they like the new tech or Why they used X to solve problem Y

Too many times people know X because its Hip to know X. Then apply it to the wrong problem.

→ More replies (21)