I've been tasked with doing technical interviews at my company,
and I have generally ask a range of OO, Java, and "good programming
technique" concepts.
However, one of my favorite exercises I give interviewees seems
to trip them up all the time, and I wonder if I'm being too much
of a hardass... it seems easy enough to ME, but these guys, when
I get them up to the whiteboard, seem to get really confused.
The exercise is this:
Create one or more classes that represent a binary tree.
This class(es) must be able to do standard sorts of operations
one would do on a binary tree in a good, OO sort of way.
A node in this tree holds only a single, String, value.
Now write for me a method named 'find' that takes an argument
of a String (or a String and a Node, depending upon your
implementation) and returns a java.util.List of all nodes,
from the node it's called upon and all descendent nodes, inclusive,
who's value matches that of the String argument.
The code must be syntactically correct, and would compile.
As an added exercise, how would you make this code thread-safe?
Seems pretty simple, huh? But most guys we've brought in just sit there
staring at the board, and have trouble even writing the basic
Node class... they get all confused, don't know how to traverse a
tree, etc.
Am I unreasonable in expecting someone to be able to do this???
In a work enviornment no, in a uni assignment no but in an interview ?
Hi Tim,
I've done heaps of interviews so I share your pain. I also found most
didn't understand the basics.
Mind you my basics were even more basic than yours. I just had a base
class, a derived classed and a polymorphic show() ... and we just
talked through various things.
Questions like how would you do this, why would you do that... when to
use inheritence vs containment. What do you think is important?
Why/why not?
I focused on depth of understanding, experience, design, their ability
to reason and make intelligent tradeoffs ... I didn't care about
syntax errors, compilers easily catches those.
So I agree, tests are a great idea.
But on OTOH personally I wouldn't test using a BinaryTree.
I have 19 years experience, all my performance reviews have been
excellent, my solutions just keep on running, I've done really well at
uni and in the field, I've implemented way too many BinaryTrees in C,
Pascal, C++ (none in Java I use TreeMap/TreeSet) ... yet I would
probably fail your BinaryTree test!
Not that I don't know BinaryTree's but an interview environment is
radically different to a work enviornment. It makes people nervous. It
would take me by surprise, I'd have to context-switch and that takes
time.
But put a keyboard under my fingers and I'll thump a BT out no
problem. Let me use my references or my past code and it's all so
easy!
But would I recall it all in an interview on a whiteboard? NO.
It's a dilicate matter of balance. Interviews ain't easy, I do
sympathize with you ;-|
OTOH not all get nervous some really shine in interviews yet they
can't program for peanuts! They present extremely well, they've got
all the lingo down, design patterns, OO-speak, buzz words, charm
galore but ... they can't program!
Another big factor are they burnt out? They may really need a big
holiday and not a new job.
Tim, above all the most important thing for me is
how-well-would-they-get-on-with-everyone?
I've worked with very clever guys but some were savages to get on
with, I hated it. I'm considered by most as easy going, I don't want
to have wars at work! Nightmares about work at home.
....
Some ideas: Maybe an 80% completed BinaryTree, they could talk about
what's missing ... or a poorly designed tree and they can suggest how
to make it good. Oh I dunno ...
Best wishes ;-)
Alex