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.

In an interview with a software company they asked me some algorithm design questions.

Being strong in mathematics I was able to solve it mathematically, but each time when I propose my algorithm they were doubtful about its working and I have to prove it with examples.

I didnt get a call for further rounds, I believe my solutions were correct.

After googling I have found answers to most questions but they were implemented in a different way.

Why do interviewers look for optimal answers rather than solutions, which came out of our thoughts rather than memorization of an optimal answer and delivering it.

share|improve this question
6  
Are you sure they were doubtful about the correctness and not just wanting to see how clearly you were capable of explaining its working? –  Peter Taylor Mar 21 '13 at 10:29
11  
"why do interviewers look for optimal answers rather than solution" - why do people overgeneralize, believing just because one interviewer acted that way, every interviewer acts that way ;-) ? –  Doc Brown Mar 21 '13 at 11:59
1  
@kevin: perhaps your answer was not as good as you obviously believe it was? –  Doc Brown Mar 21 '13 at 12:01
    
There's some unclearness in your question: you first say "they were doubtful about its [the algo's] working" but then you continue with "found answers to most questions but they were implemented in a different way.". Did they: a. thought your mathematical description of the algo was incorrect? b. asked you to (maybe pseudo) code it and doubted THAT or c. for either case, did they doubt that it will work or did they doubt its performance? –  Shivan Dragon Mar 21 '13 at 12:34
2  
Mark Twain once said that finding the right word for a sentence is the difference between lightning and the lightning bug. So it is with having an optimal algorithm - at least for some jobs. There are tasks for which an algorithm who's running time scales as n^2 is just as useless as not having any solution at all. Then again it could be that they just expected to see the solution they saw in school. We weren't there, we don't know what line of work they're in, there is no way for us to know. –  Charles E. Grant Mar 28 '13 at 0:35

5 Answers 5

up vote 8 down vote accepted

Maybe the interviewers where actually testing your education in algorithms rather than your ability to come up with an algorithm. It is quite easy to come up with an algorithm for sorting (Bubblesort, etc.). Its quite hard to develop an algorithm like Quicksort without education in existing algorithms.

Another thing is that while you can phrase math/formulae/algorithms in different ways and they - in essence - mean the same thing, another person might not understand your view if the person knows the other formulation of the principle. If you have a physics background you might use different notation than a person with a maths background or a CS background (even within fields there is an abundance of different notations). So for example a CS person looking for geometry skills and asking about transformations might look for certain "buzz words" like transformation matrices and matrix multiplication while a person with a physics background would definitely know how to transform a coordinate system but might start to talk about vectors and pseudo-vectors and invariants under transformation. The physics person of course is convinced to have shown understanding, the CS person might thing: "what weird stuff was the interviewee talking about?"

Bottom line: don't take it personal, there is a certain amount of randomness in hiring and interviews.

Also: Did you stay calm or did you appear stressed out? Did you show interest in the question or was it more of a "chore". Maybe it was not your algorithm or math skills that got you off the list but "soft skills".

share|improve this answer
    
I couldn't come up with optimal solution first but i certainly optimized it using different CS concepts :). –  kevin Mar 21 '13 at 7:23

As an interviewer we're also doing some algorithm questions, but all that is not so much about the algorithm itself. It's more how does the candidate work, what steps does he take, how does he react, if we raise the stresslevel.

share|improve this answer

Many interviewers are not looking for you design a solution. They are looking for you to parrot a text book, but probably think that thats designing the solution themselves, and are incapable of recognizing, let alone analyzing, independent though. If you are a good parrot, you get the job, if not, they pass you over.

Thank yourself lucky you got out before they fed you crackers......

share|improve this answer
    
-1: I don't know where you have interviewed. I have had a couple of interviews like that at places I wouldn't want to work. Better shops want to see a candidate demonstrate some understanding and some problem-solving ability. –  kevin cline Dec 15 at 18:45

Some hiring managers really don't want people who can think through and analyze a problem to develop a solution. They are more comfortable with (maybe even less threatened) by those who will slug through the problem to come up with a solution no matter how inelegant and unmaintainable the solution is.

share|improve this answer

In an interview, I will often ask questions about details of how an algorithm the candidate wrote will work in certain cases. Many times this is due to a flaw in the algorithm, and I want to see how easy it is for them to spot it, or to be led to spotting it. Problems or not, I'm also looking to see how well they can explain what the code they wrote actually does.

I also question them about other approaches, and how those approaches may be more or less efficient (often, differently efficient). In most of these cases, it's testing the candidate's ability to find different solutions and contrast them. For the questions we have the candidates code answers to, the efficiency would never end up mattering, but whether they can analyse the efficiency of a given algorithm and describe trade-offs between it and other algorithms is an important thing to know before hiring someone.

share|improve this answer

Your Answer

 
discard

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.