Binary tree print zig zag

i used the logic of how we print level order in a binary tree
added a stack to store data until i finish a level so that i can get reversed output of level but i aint able to
i know my code doesnt work properly
please help me solve this

https://ide.codingblocks.com/s/45585 // i have added comments for my steps

https://hack.codingblocks.com/contests/c/511/481

Hey Jai, to print the level order of a binary tree, use a queue. Every time you pop a node from the queue push its children to the queue and when the queue becomes empty you level order is already get printed.

but its not zig zag
i have implemented the level order output code and modified it with stack and x value so as to try to print lvl order in zig zag formt but am unable to

check for this input as given in test case
10 true 20 true 40 false false true 50 false false true 30 true 60 false false true 73 false false

for ZigZag you can take two stack in first push the root and then push its children in another stack, then pop the children from another sack and push its children in first stack ans so on.
you can even refer the following link: