Tuesday, July 3, 2018

Coding Interview: Pseudocode

"Interview is an artificial reality designed by companies to keep people out" - Manager Tools
Many companies won't offer helpful feedback on your interview performance. I think that feedback is a fair game, and the process should be transparent.


This is a follow-up on the older post, Interview Insider: Coding fluency. A reader asked my opinion on using pseudocode to document his thoughts while working on the solution. Specifically during a phone screening, when diagramming may not be a possibility.
I want to start by quoting Steven Skiena's TADM[1]:
The choice of which notation is best depends upon which method you are most comfortable with. I usually prefer to describe the ideas on an algorithm in English, moving to a more formal, programming-language-like pseudocode or even real code to clarify sufficiently tricky details.
A common mistake my students make is to use pseudocode to dress up an ill-defined idea so it looks more formal. Clarity should be the goal.
Clarity is the goal indeed. There could be cases when using pseudocode is justified. However, I think those are rear.

I recommend sticking to the plain English (and diagramming, when you can) until the solution is crystal clear. It’s also easier for your interviewer to understand. Note that you need to make sure that your interviewer is OK with your solution before coding.

Using pseudocode (same as actual code) prematurely can send you wrong way, and you will waste extra time digging yourself out. I noticed that if I stay on a higher level, I generate more creative ideas. The interview has two-parts: head-up, when you look for solutions, discuss, and debate. And then head-down, when you demonstrate your ability to implement the agreed solution quickly and accurately.

Finally, interviewers in big companies typically offer you to code in the language of your choice, and pseudocode is considered as a red flag. E.g. the candidate could be rusty in coding or trying to obscure “an ill-defined idea”. In the end, if you code every day, it should be even faster to code in your language than in pseudocode.

External links

  1. The Algorithm Design Manual on Amazon.

This quote is on page 12, and this is how much I read so far. Actually, the book is surprisingly refreshing, and I have no reservations recommending it.

No comments:

Post a Comment