How to delete minimum node from a Binary Search Tree?

This is going to be simple.  As you already know that the data in Binary Search Tree is already organized, you know exactly where to find the node with minimum value. If you start from the root and keep going to left till you can traverse the tree, the last node is going to be the minimum one. Here is the C++ code for that. I am trying to put the codes in proper indentation, but its not working for me with the blog.

struct tnode *delmin(struct tnode *p){
struct tnode *temp=p;
while( temp->left->left != NULL){
temp = temp->left;
return p;

Now try to write the code for deleting the maximum one. Isn’t it quite simple and obvious?

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: