3 ms·
Reversing a tree (max element on the left) is absolutely CS homework (though probably 201). I'm sure I had to do that at least once or twice. But you can also
by hinkley 8y ago
Reversing a tree (max element on the left) is absolutely CS homework (though probably 201). I'm sure I had to do that at least once or twice. But you can also avoid that most of the time by writing a second in-order traversal algorithm that runs from right to left.
But why would I need a data structure where I have the elements by the leaves instead of the roots? Make the nodes doubly linked (parent element) and you get the same effect without all the grandstanding.