Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

So, I've just realized that some employers may ask an interview question that is relative to some complex mathematical algorithm.

It seems like answering these questions is a skill in its own right. After all, I'm quite good at developing algorithms when the need arises, such as graphical algorithms, generic problem solving, or basic pattern matching, but I am not a mathematician.

These problems require a completely different type of algorithmic thinking not necessarily had by most programmers, so where do I develop these skills? Is there a book I can read on this subject?

share|improve this question
Have you been asked a question related to a complex mathematical algorithm? Only the most selective employers would ask such questions. I've never been asked such a question, in at least a couple of dozen interviews over three decades. –  kevin cline Nov 7 '11 at 5:08
When I search for interview questions, it seems like most involve some sort of specific mathematical algorithm... for instance, the date calculation given in seconds since another date. Doesn't sound like much. Factoring in leap years, etc, try calculating it in your head? I can't even think of an algorithm that would calculate it on my own; I'd need google at my disposal to find an existing algorithm. –  William the Coderer Nov 7 '11 at 5:18
@kevin clise: A job interview for a DSP programming position (even entry level) might very likely include some question on complex mathematics. –  hotpaw2 Nov 8 '11 at 2:09
@William: wow, someone really asked you that? Still, I wouldn't call it complex. Nor would I expect someone to know how to do that correctly without a bit of research. Few people know that century years are not leap years, unless the year is divisible by 400. –  kevin cline Nov 8 '11 at 16:32
add comment

migrated from stackoverflow.com Nov 7 '11 at 1:19

This question came from our site for professional and enthusiast programmers.

7 Answers

up vote 11 down vote accepted

You should try getting started with TopCoder problems. Go to the algorithms arena and enter some practice sessions. There you may start warming up your brain.

Also, you can try reading Algorithms for Interviews.

Skiena has also a very nice book on Programming Challenges that might be useful to solve technical challenges.

share|improve this answer
add comment

There are a number of books on programming interviews.
Unless you are going for a specifically highly technical job I wouldn't worry about getting too mathematical, although a read of the algorithm design manual is always worthwhile.

Personally I hate the brain teaser type problem that rely on a single ah-ha moment. The real point of these impossible questions is to see how people reason, but a lot of companies missed this point and unprepared interviewers just look for the answer. If you think you are going to such a place look at How to move mnt fuji

share|improve this answer
add comment

Finding a job is crazy these days. Not only do you need to cram for industry certifications, but you need to cram for interviews as well. There are a number of books that cover the kinds of questions that commonly arise.

Cracking the Coding Interview: 150 Programming Questions and Solutions

Programming Interviews Exposed

If you think your interviewer is going to focus on basic algorithms and data structures, then you should review those areas. Also as others have suggested it might be a good idea to review algorithm design.

I've been interviewing for a few jobs recently and haven't found too many algorithm type questions although I'm certainly not applying for jobs at Google or Microsoft.

I've found that behavioral questions are quite common, so definitely be prepared to answer those kinds of questions too.

Be prepared to deal with annoying HR people as well. I was at an interview recently where I got asked questions like "What makes for a good 'Use Case'?", "What makes for a successful IT project?". The questions themselves weren't that bad, but when I gave my answers the interviewer said "No that is completely wrong" and came up with some canned definition he had from somewhere.

share|improve this answer
add comment

There is only one book you need, and that's "Introduction to Algorithms" by Cormen, et al. Just read and fully understand the material in there, and it will get you through any algorithm-based interview. To get a sense of the types of questions to be asked, you should also read "Programming Interviews Exposed" by Mongan, et al. and "Cracking the Coding Interview" by Laakman.

share|improve this answer
add comment

I think the best way to prepare is not to prepare for the interview, but to make your knowledge of Computer Science solid. After having flunked in a couple of high profile interviews involving algorithms and puzzles, I decided to make my foundations solid and this will automatically take care of the interview. Few of the books I would recommend:

  • Introduction to Algorithms by Cormen et al

  • Programming Pearls by Jon Bentley

  • The highest voted interview question on stack-overflow, at least the initial 200 of them.

Speaking of mathematics, Martin Gardner's My Best Mathematical and Logic Puzzles, The Colossal Book of Mathematics: Classic Puzzles, Paradoxes, and Problems and Peter Winkler's puzzle books are of great help.


share|improve this answer
stackoverflow.com/questions/tagged/… link is dead. –  Shouvik Nov 29 '13 at 8:18
add comment

Often, questions like this are not about finding an actual solution, but about demonstrating that you know how to find the solution.

Responding with "Off the top of my head, I'm not sure how to implement a solution to this problem, but I suspect that Numerical Recipes might have some useful pointers" would often be sufficient to show that you wouldn't be left completely in the dark.

share|improve this answer
add comment

Regarding "complex mathematics questions":

If you are interviewing for a digital signal processing related programming position, then you will want to review your DSP textbooks, and perhaps refresh your knowledge on the algebra and calculus of complex variables (e to the i pi, Z transform poles and zeros, etc.)

In general, you will want to review the mathematical (or statistical, etc.) algorithms related to the requirements of the job to which you are applying. If you are qualified, you will know which textbooks to pull out of storage, or get from the local library for a quick review.

share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.