books book reviews

computer programming books

reviewed by T. Nelson

Score+4

Cracking the Coding Interview, 6e

by GL McDowell
CareerCUO, 2015, 695 pages
reviewed by T. Nelson

Y es, this is a self-help book for computer programmers, but it's also useful to ordinary people who want to improve their coding skills. It consists of 189 programming problems they're likely to give you, along with complete solutions and discussion. Sections include big O notation, trees and graphs, bit manipulation, recursion, databases, threads, and object-oriented programming. The author really likes Java, but there are also examples in C/C++.

Fully two-thirds of the book consists of solutions to the programming questions, so it's not really a 700-page book. The questions are not intended to be difficult. The idea is that the companies are testing whether you can write clean code and test for edge cases. In later chapters, the solutions are so long you'd probably need several whiteboards and several boxes of markers. And a long-sleeved shirt, in case the interviewer was evil and didn't give you an eraser.

One thing that struck me is that the author rarely uses math, even when the question implicitly calls for it. She could have gotten more concise code if she had, and you'd get points (at least from me if I were hiring a programmer, which I'm not) if you demon­strated a lot of knowledge about math and numerical algorithms. There's also nothing on specialized topics like hard­ware interfacing, network TCP/IP program­ming, data acqui­sition and analysis, commer­cial trans­actions, or cryp­tog­raphy (which I just discovered is an enormous and complicated topic). I suspect many jobs in the real world are not just for somebody who knows how to use a linked list, but somebody for a specific job that requires specialized knowledge. But I could be wrong.

The other thing that struck me was the author's description of the interview process. She says it lasts only a few hours. They ask you questions and you have to write code on a whiteboard. Then, apparently, they tell you whether you got the job and hire you, or not.

That's not how it works in science. We give a lecture in a big auditorium. Sometimes they treat you like a rock star and forget about asking questions, mob you, and start trying to arrange collaborations. Other times they just glare at you the whole time as if they hate your guts. One place kept me there for five days and gave me a schedule of when I would eat, where I'd go, and who I'd have to give talks to. They forgot all about the eating part, so I ended up giving talks on an empty stomach. If they don't hire you, they never, ever tell you that. But the biggest difference is that in science you have to pay them to hire you. No grant, no interview.

Getting back to the book, I found the most interesting section to be the math and logic puzzles, which apparently are now forbidden to ask in an interview. Here's an example from page 122:

You have 20 bottles of pills. 19 bottles have 1.0 gram pills, but one has pills of weight 1.1 grams. Given a scale that provides an exact measurement, how would you find the heavy bottle? You can only use the scale once.

I admit I would have complained about that one. Rule #1 in a pharmacy is: you touch somebody's pre­scrip­tion medicine, you're out the door. Anyway, this puzzle has a clever solution. Hint: you have to open the bottles. Just grit your teeth and pretend they're just coins.

aug 23, 2023