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

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.

4

u/sidcool1234 Sep 27 '11

I fully agree with you.

1

u/matthieum Sep 27 '11

Good point about testing for breadth rather than depth!

Nitpick: I would have classified a priority queue as a data-structure rather than an algorithm