This post is completed by 2 users

  • 0
Add to List

179. Binary Tree Deletion

Objective: Given a binary tree, write an algorithm to delete it.

This is one of the basic problems in trees. if you are new to trees then this problem will help you build your foundation.


  • To delete a binary tree, we need to set all the node objects to null then garbage collection will take care of the rest of the things. If you are writing the code in C/C++ then you will have to clear the allocated memory by yourself.
  • Do the post-order traversal and set the node to null.


Deleting Node:4
Deleting Node:5
Deleting Node:2
Deleting Node:3
Deleting Node:1