This is not homework, this is an interview question.
The catch here is that the algorithm should be constant space. I\'m pretty clueless on how to d
If you are using a downwards pointer based tree and don't have a parent pointer or some other memory it is impossible to traverse in constant space.
It is possible if your binary tree is in an array instead of a pointer-based object structure. But then you can access any node directly. Which is a kind of cheating ;-)