This is my tree(without the underscores):
_________5
________/ \
_______4___8
______/____/ \
____11___13__4
____/ \________\
___7___2________1
I'm required to print it in this format.
Currently I have this code:
It works fine enough but it prints zeros for the leaf nodes. I've tried putting an if condition if(bt->getData() != 0) before the cout and it works but the 4 moves up to the 5. Any ideas on how to correct this?