title: freeing memory of a binary tree C
body: <p>I would like to free memory from my allocated binary tree what traversal is the best for doing so?</p>
  
  <pre><code>typedef struct Node{
  struct Node * right;
  struct Node * left;
  void * data;
  }Node;
  
  
  typedef int (*cmp) (void*,void *);
  
  
  Node* init(void * element){
      Node * newNode=(Node*)malloc(sizeof(Node));
      newNode-&gt;data=element;
      newNode-&gt;left=NULL;
      newNode-&gt;right=NULL;
      return newNode; 
  }
  
  void  insert(void * element, Node** root,cmp compareTo){
      if(*root==NULL){
          *root=init(element);
          return;
      }
      if(compareTo(element,(*root)-&gt;data)==1)
          insert(element,&amp;((*root)-&gt;left),compareTo);
      else
          insert(element,&amp;((*root)-&gt;right),compareTo);
  }
  </code></pre>