Re:Why it’s hard for programmers to write a program to flatt...
by skybrian on Friday February 24, 2017 @12:04PM
(#13725440)
A slight rewrite makes this a reasonable question in Java. A list of lists has a tree structure and asking candidates how to print the items in a tree in depth-first order is reasonable.
The main issue is that you'd never use a list as a tree node in Java. There would be an explicit Node class of some sort.
I do ask a question where one possible solution is to define your own Node class, build a tree, and print it out. But you can also solve it without even realizing you're working with a tree.
The main issue is that you'd never use a list as a tree node in Java. There would be an explicit Node class of some sort.
I do ask a question where one possible solution is to define your own Node class, build a tree, and print it out. But you can also solve it without even realizing you're working with a tree.