M
MCheu
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???
- Tim
The only two points I have a problem with are:
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.
You might want to specify the tree type and operations you want
implemented, because my idea of "standard" might be different than
yours. The basics might be search, insert, delete. Other functions
that may or may not make it into someone's idea of "standard"
functions might be the order traversals, finding the level of an
entry, rebalancing (if required by the requested tree type), and
likely others that you've thought of, but I've not.
Also a generic BT only specifies a nodes with data and two node-links,
with no specific insertion organization. This may be the source of
the traversal confusion, because the output from the order traversals
will be different depending on how the BT was implemented (though I
guess the code would be the same).
The code must be syntactically correct, and would compile.
This is another bone of contention. Unless you give the applicant a
computer, with a compiler installed on it, this isn't terribly fair.
Typos and other small error can arise in hand written code, making
impossible to compile, and yet would be easily catchable under normal
conditions.