3 ms·
Is there something special about reversing a binary tree? AFAIK, you could swap the child pointers and do that recursively for the child nodes. You could also
by tropo 8y ago
Is there something special about reversing a binary tree?
AFAIK, you could swap the child pointers and do that recursively for the child nodes. You could also do things O(1) by just changing the comparison function, perhaps by wrapping it to negate the comparison.
- shaftway 8y agoThis is a specific, well-known case. Max Howell (the author of Brew) was rejected by Google. One of his interviewers asked him to invert a binary tree. https://twitter.com/mxcl/status/608682016205344768?lang=en https://twitter.com/mxcl/status/608682016205344768?lang=en