C program to delete a tree

Write a C program to delete a tree(i.e, free up its nodes)


#include<stdio.h>
struct binarysearchtree
{
int data;
struct binarysearchtree* left;
struct binarysearchtree* right;
};
typedef struct binarysearchtree* tree;

void tree_free(tree T)
{
if (T==NULL)
return;
else
{
tree_free(T->left);
tree_free(T->right);
free(T);
}
}


Click Here For Questions

No comments:

Post a Comment