Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?


migration rejected from May 4 '14 at 10:20

This question came from our site for professional and enthusiast programmers. Votes, comments, and answers are locked due to the question being closed here, but it may be eligible for editing and reopening on the site where it originated.

closed as off-topic by gnat, MichaelT, GlenH7, Bart van Ingen Schenau, amon May 4 '14 at 10:20

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions seeking career or education advice are off topic on Programmers. They are only meaningful to the asker and do not generate lasting value for the broader programming community. Furthermore, in most cases, any answer is going to be a subjective opinion that may not take into account all the nuances of a (your) particular circumstance." – gnat, Community, Bart van Ingen Schenau, amon
If this question can be reworded to fit the rules in the help center, please edit the 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

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.


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.


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

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.



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.


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.


Things get changed, right now in the market there are more preparation book options. Out of them, I recommend the

  1. Programming Interviews Exposed: Secrets to Landing Your Next Job
  2. Cracking the Coding Interview: 150 Programming Questions and Solutions
  3. Elements of Programming Interviews: The Insiders' Guide

Also, you should use the websites like leetcode and careercup. If you feel necessary, you can always consult the brick books, like Introduction to Algorithms and Algorithms.


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