Take the 2-minute tour ×
The Workplace Stack Exchange is a question and answer site for members of the workforce navigating the professional setting. It's 100% free, no registration required.

I have seen lot of interviewers asking advance algorithm and data structure questions while job doesn't require any knowledge of them. It is true for a lot of times so why interviewers ask such questions?

share|improve this question
What sort of programming jobs don't require knowledge of algorithms and data structures? Without those basics all you can do is thoughtlessly copy data around. You can't even design a good data model. –  kevin cline Jun 14 '14 at 16:20
@kevincline most web development in standard website shops for example. –  Benjamin Gruenbaum Jun 14 '14 at 21:32
Associative arrays aren't "knowing data structures", your wife didn't have to spend a minute thinking about the backing hash table or red black tree. That's the beauty of it :) –  Benjamin Gruenbaum Jun 14 '14 at 22:01
For many there's a simple answer: they do it because Google does it. –  DJClayworth Jun 15 '14 at 3:18
I'm weeping for the industry right now. –  Bmo Jun 16 '14 at 10:17

3 Answers 3

It's mostly a test of your understanding of the fundamentals of Computer Science (which should be a prerequisite for any programmer).

Software development has evolved to the point where the fundamentals of building good product have been abstracted away from the average developer. "High-level" languages have bred a new crop of copy-n-paste programmers that don't know why it's working, only that it does. While it's not easy, almost anyone can learn an API nowadays.

Asking about algorithms, data structures and design patterns helps a lot of companies weed out the programmers that can raid Stackoverflow for good answers, without understanding the operating principles behind them. You'll also find that many companies that ask about such fundamentals, build in a variety of platforms. Rather than ask for things peculiar to a specific language/platform, they'll open the interview with more general computer science questions.

Knowing the fundamentals of CS helps you make better higher level decisions when programming. If I were an employer, I'd want to recruit a programmer that knows the difference between a Stack and a Queue; a ArrayList from a LinkedHashSet; Bubble sort from Quick Sort; There are performance/design implications for these decisions. It's important to understand them, rather than just ripping something off the net (by an author that may have made the wrong decision without your understanding/knowledge). Knowing the solution is not understanding the solution

share|improve this answer
@VarunAgw - OS's and Compilers are ultimately built on what? Algorithms. Data Structures. Logic. Fundamentals. That's what everything programming ultimately boils down to. Rather than split hairs between C# and Java, I'd rather ask you questions based on something they both have in common –  kolossus Jun 15 '14 at 0:16
@Dukeling - If I were an employer, I'd want to recruit a programmer that knows the difference between a Stack and a Queue; a ArrayList from a LinkedHashSet; Bubble sort from Quick Sort; Threads vs Processes. There are performance/design implications for these decisions. Better understand than just rip something off the net that may have made the wrong decision without your understanding/knowledge. Knowing the solution is not understanding the solution. I'm not saying that you must understand the solution 100% of the time, but as an employer, I'd be happier to shell out the bucks if you did. –  kolossus Jun 15 '14 at 0:20
+1 for "Knowing the solution is not understanding the solution". –  Md. Mahbubur R. Aaman Jun 15 '14 at 10:07
@VarunAgw, when you are a manager, you can ask whatever questions you want to try to figure out who is and is not capable of doing the job you have. The people you are interviewing have a reason for asking this and it doesn't matter what that reason is ultimately since you will have to have an acceptable answer to move through the process. But since these are questions that test your fundmental understanding of computer science, I don't see them disappearing any time soon. Maybe the weed out some potentially good people but they also weed out most of the incompetent. –  HLGEM Jun 16 '14 at 17:23
  • Can you write working code?

    This is of course assuming you're actually asked to write actual code in the interview (white-board style).

    This isn't so much about not even having a single typo in your code, but more about just knowing what basic constructs like for-loops look like, knowing how to put the bits together and proving that you've actually written a bit of code in a language to know most of the most common methods / classes (apparently interviewers have a bit of a problem with candidates that can't even pass the fizz buzz test).

  • Can you think through a problem?

    This definitely doesn't just apply to algorithms.

    You need to be able to understand the problem, analyse the requirements, pick appropriate data structures and algorithms, write the code / walk through the approach, and analyse it - that's required for many / most (non-bug-fix) programming tasks.

  • Can you communicate well (about programming)?

    Do you understand the problem as described?

    Do you ask for clarification when required?

    Can you explain the high-level approach before you start writing the code?

    Are you able to explain your code after the fact?

    The ability to communicate well is important in your day-to-day job as a programmer.

    Your boss shouldn't be concerned that you're not going to be able to understand the explanation of a problem, not ask for clarification when things are unclear (and just make some radical assumptions), have no ability to walk through how you're planning to solve any given problem and/or have no ability to explain code you've written to anyone else.

  • Do you have a decent knowledge of data structures and algorithms?

    While you may be asked about an advanced data structure or algorithm that you'll never use, knowledge of this data structure may be a fairly accurate indicator that you know pretty much all the basic ones quite well.

    I'm also fairly sure you can stick to simple data structures or algorithms (linked-list, array, binary search tree, binary search, etc.) in many cases and still do well in this specific aspect - while an advanced data structure or algorithm may be better suited to solve the problem at hand, you could often fairly efficiently solve the problem with a combination of basic ones - there's still picking between them based on appropriateness and combining them appropriately.

    And you definitely need a decent knowledge of data structures and algorithms - you can't be good at what you do if you don't know when to use which tools in your toolbox.

  • Can you analyse time and space complexity and weigh choices up against each other with them in mind, making the most appropriate choice for the situation?

    Any data structure or algorithm question should involve complexity, and it will be very significant to your day-to-day job - no-one wants you to, for example, write code that endlessly does linear search through a large unchanging array because you don't know what's going on on the low level.

share|improve this answer

There are probably two main answers:

Firstly, because it's an opportunity to see how a candidate approaches a problem. Even if you don't know the specific solution to the problem immediately, how you explain how you would approach the problem may be revealing about your ability to think clearly, to understand the problem, and demonstrate other qualities like patience.

The second answer is that they are just doing it because it is a way of demonstrating how much a candidate knows, and that they believe other companies do the same, and so the question acts as a fairly arbitrary hurdle that they want candidates to jump over.

share|improve this answer

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.