Reversing a binary tree and other great interview questions

Reversing a binary tree and other great interview questions

I saw an old tweet (yeah, I know, twitter archaeology) by Max Howell who complains about recruiters who have ignored his achievements.

Firstly, I thought “Yeah! Exactly!”. I understood his outrage because similar behavior was exactly what convinced me to quit my previous company when they had decided that I could not be promoted: Sorry, we are going to ignore everything you have been doing for the last three years and make a decision based on 20-minute long interview (it is not a quote).

If the recruiters had looked at Max Howell’s GitHub account they would have concluded that Max is a very competent programmer. Let’s look at the numbers: 1k contributions in the last year, (very) active on GitHub since 2009, the most popular repository has 7k+ “stargazers”. Impressive.

Can we blame recruiters for ignoring real experience and focusing on performing structured interviews with reality-unrelated questions? Is there at least one good reason to conduct a whiteboard interview?

Are you interested in data engineering?

Check out my other blog https://easydata.engineering

What do recruiters want?

In my opinion, when a recruiter asks you to solve a problem on a whiteboard they do not want to see a solution. They do not want to know whether you managed to memorize a few algorithms! Seriously.

So what do they want? They want to check whether you:

  • can explain a solution to others
  • can reason about code without running it
    That ability is really helpful. Do you know anyone who cannot say a word about code if they do not run it and check what the code is really doing? Isn’t it annoying?
  • know that data structures exist and you do not need to reinvent them

Things get more interesting if you do not know how to solve the problem. In such case you have an opportunity to show that you can:

  • ask for clarification
    Asking for more information is difficult. You need to admit your lack of knowledge. It is particularly hard when you are talking about something which is supposed to be your area of expertise.
  • understand a problem you are not familiar with
  • create a solution
    Create it, not copy-paste. Show the recruiter that you can finish a simple task without using Google or asking a question on StackOverflow.

Reversing binary tree and other questions

Now we must pretend we are hiring a programmer. We have already decided to base our decision solely on candidate’s ability (or inability) to finish some tasks. Should we hire a person who cannot solve a problem?

As a matter of fact, the task does not matter. It makes no difference if the recruiter asks you to reverse a binary tree, sort an array, write the binary search algorithm, etc.

We may be annoyed by being asked to do such things over and over again. On the other hand, imagine what could we accomplish if we spent half as much time learning the fundamentals of computer science as we do complaining about “irrelevant” interview questions.

Have I offended you, so you stopped reading or can I explain why it is crucial to know and understand such concepts?

Producing code is not enough

Sadly, we need interviews to filter out people who can only copy-paste code and talk a lot about their “achievements” (which are in fact achievements of their coworkers) instead of doing things. We need a way to test whether a person is capable of thinking and problem solving.

Should we give up and test only how fast an interviewee can find some information using a search engine? Is it really the only skill we need?

I worked with a man who could produce code only if it had been posted somewhere on the Internet. Usually, he was sitting next to someone else who was working. It was his way of “pair-programming” (in this case it means that one person is thinking and writing code while the other is sitting next to the screen, staring at the window(!), talking about work-unrelated things, or eating potato chips).

If I must write an algorithm on a whiteboard to avoid such situations in the future, I will gladly do it.

Obviously, knowing some algorithms and data structures is not enough either. Nothing is more important than real world experience. Unfortunately, you cannot easily compare experience of two different programmers. If you think it is possible, please tell us how to do it and fix IT recruitment once and for all!

Sad truth about your GitHub projects

Your GitHub account does not count as much as you wish it was. You can be sad because of that or get mad at me. You can start yelling, rage-tweeting, sobbing or stamping your feet, but it is not going to change anything.

It would be great if we could discuss our GitHub projects with recruiters, but no one has time to review our code before a meeting.

Learning the basics

You do not need to study at a university for five years. All you need is a book, or two books. In fact, you do not even need a book. You can just read its table of content and google the topics on your own.

Remember, your goal is to be familiar with the topic, not to learn it by heart.

I recommend to start with those two books:


Remember to share on social media!
If you like this text, please share it on Facebook/Twitter/LinkedIn/Reddit or other social media.

If you watch programming live streams, check out my YouTube channel.
You can also follow me on Twitter: @mikulskibartosz

If you want to hire me, send me a message on LinkedIn or Twitter.


Bartosz Mikulski
Bartosz Mikulski * data scientist / software/data engineer * conference speaker * organizer of School of A.I. meetups in Poznań * co-founder of Software Craftsmanship Poznan & Poznan Scala User Group