I’m programming a BinaryTree project. I finished all (insert, delete, create, find) but one function, the printing operation. I’m supposed to print it like this:
5
46
X557
XXX6XXX9
Basically print all the nodes, but print an X if the node is empty. I’ve been trying to figure out how to do this and I keep hitting a dead end. Would this be something like inorder-traversal?? Thank you
Use a Level-Order traversal (Breadth First Search) printing each node as you go through a level, with a newline at the end of each level.
You can find BFS pseudo-code here