← Back to context

Comment by mercutio2

11 years ago

Note that "invert" in this context is fairly ambiguous. I suspect the interviewer meant reverse, which is, I agree, utterly trivial.

I, and apparently many others in this thread, spent some time trying to ferret out an answer to what it would mean to invert a binary tree: at first thought it would imply a collection of nodes all pointing at their parents, which seems not very useful (and would require more than 10 lines of code to whiteboard reasonably).

Much of the discussion is about whether or not the problem was described in sufficient detail or not.

The question is definitely not described in sufficient detail. That's usually on purpose. The interviewer WANTS the candidate to realize that too and ask the questions necessary to actually understand what they are trying to solve. It's very analogous to nailing down specifications on a new feature or something like that.