Does anyone understand this "tree equality" interview question?

From here: https://beyond.codes/reflections/jane-street/

The second interview was about binary trees. I was asked to implement binary trees in Clojure. I quickly wrote the data structure and the equality comparison function. And then I was asked about whether there’s some problems with the equality comparison function that could make it inefficient – somebody could construct a binary tree that would take a long time for the equality comparison function to finish.

I spent some time to realize that if you pass a recursive binary tree, the equality comparison function would never return. They soon pointed out that you didn’t need a true recursive binary tree. A binary tree that reused its nodes would have the same effects.

What does a "true recursive" binary tree even mean? How can a tree ever reuse its old nodes without becoming a graph?

Posted May 29, 2016, 8:28 PM UTC

510
Loading comments…