Traverse by Zig-Zag order
/*** zig-zag traversal of a binary tree. ***/ #include <iostream> #include <stack> #include <vector> using namespace std; struct node{ int val; node *left, *right; }; void zigzag(stack<node*> pre, vector<node*> *v, int flag) { if (pre.empty()) return ; stack<node *> cur; while (!pre.empty()) { node *n = pre.top(); pre.pop(); v->push_back(n); if (flag%2 == 0) { ...