Tech writer interviewing: basic algorithms

When you’re interviewing for a technically oriented tech-writing job in the software industry, chances are fairly good that at some point in the process, you’ll be asked to read some code and explain what it does.

So before you apply, I strongly recommend familiarizing yourself with some common simple things that a brief code sample might do.

For example, I recommend having a general sense of how the following things work (in simple implementations), and more or less what they look like in code in at least one common programming language:

  • sorting an array
  • merging two arrays
  • reversing a string or an array
  • computing a factorial
  • recursion in general
  • finding prime factors of a given number
  • searching in a string or an array
  • searching in a binary tree
  • storing and retrieving data in a hash table/hash map/associative array/dictionary

(I also recommend being familiar with the data structures that underlie those algorithms and concepts, such as strings and arrays and hashes and trees. And being familiar with coding structures like function calls and loops. But I feel like familiarity with simple data structures and control flow is more common among tech writers than familiarity with simple algorithms.)

If you’re familiar with any C-like programming language, then you can probably trace through a given simple code sample and figure out what each line does. But recognizing conceptually what the code sample is meant to do is a huge step up over just being able to describe what each line does.

Here’s a made-up example to demonstrate what I mean (but please don’t focus too much on this example; I just made it up off the top of my head):

If you see code that says this (this is pseudocode, not any particular language):

array a[2, 3, 5, 7, 11, 13];
foreach i in (1..length(a)):
  print a[i];

you could certainly describe it accurately by saying “The first line initializes an array with the numbers 2, 3, 5, 7, 11, and 13, and then there’s a loop, and the loop prints the first number in the array, and then it prints the second number, and then…” And so on. And that would demonstrate that you’re familiar with the general syntax of the programming language in question, which is a fine thing to demonstrate.

But it would probably be more useful and informative to describe that code sample in higher-level conceptual terms, such as: “This prints out the first six prime numbers.”

Of course, even after you recognize the general pattern of the code, you still need to analyze it carefully to make sure it really does what you think it does.

(In a live interview, you might want to do both the detailed talk-through and the general conceptual description, so the interviewer can hear your thought process. “Hmm. First it initializes an array, and I see that those are prime numbers, and then there’s a loop that prints out the items in the array in order, so I guess what it’s doing here is printing out the first six primes.” That way, even if you get the concept wrong, at least you’ve shown how you approach the problem.)

I know that recognizing the concept of what the code is doing may be easier said than done. For example, if you don’t have a computer science or math background, then you may not know what computing a factorial looks like, nor what prime numbers are.

But that’s why I recommend doing some research before your interview. Learn about some basic algorithms. (You could even do a web search for [basic algorithms].) You don’t have to memorize them, and you don’t have to be able to implement them yourself, and you certainly don’t have to be able to recognize and name a specific algorithm like Quicksort or a specific hash function or the Sieve of Eratosthenes. But being able to recognize the general concept of sorting or hashing or primes (for example) is a good idea.

(See also my 2013 post about applying for tech writing jobs.)

Join the Conversation