Delete all the nodes from a binary tree
To delete all the nodes, you will have to visit all the nodes.
There are three ways to traverse the binary tree :
- Post order
To delete all the nodes, we will have to make sure we do not delete a parent before we delete all of its children. Because if we delete the parent, then we lose the pointers to its children.
Hence, we will have to use the Post order traversal.