when I am submitting the compiler is not mentioning the type of error ,it is just showing error,please check my code
Doubt in the answer
@Adhyayan,
https://ide.codingblocks.com/s/221000 corrected code.
Few errors:
- Do addfirst instead of addlast.
- specify the type of LinkedList or what data your Linked list will hold.
- When c==0 we will add the left node instead of the right node.
- One of your brackets was at the wrong position, which terminated the while loop after first iteration.
Please reply on this thread if you have further doubts, else please mark this doubt as resolved. 
Sir when c==0 means we have already printed root node ,now we have to move on level 1,1 means odd and that means left to right print ,in order to print left to right ,we should add first the right and then left because first one inserted will be deleted last ,but in here you are doing the reverse???
@Adhyayan,
Print the zig zag order i.e print level 1 from left to right, level 2 from right to left and so on. This means odd levels should get printed from left to right and even levels should be printed from right to left. Each level should be printed at a new line.
As mentioned in the question, now after we print our root, c is still 0, it is not updated yet, hence we need to add elements from left to right when c is even.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.