I am able to understand preorder traversal without using recursion, but I\'m having a hard time with inorder traversal. I just don\'t seem to get it, perhaps, because I have
Here's an iterative C++ solution as an alternative to what @Emadpres posted:
void inOrderTraversal(Node *n) { stack s; s.push(n); while (!s.empty()) { if (n) { n = n->left; } else { n = s.top(); s.pop(); cout << n->data << " "; n = n->right; } if (n) s.push(n); } }