Just a sidenote!
in the add function should be like this:
When the left pointer is not null and the right pointer is nullCode:void add(int x, node** root){ node* new_node = (node*) malloc(sizeof(node)); if (*root == NULL){ *root = new_node; (*root)->data = x; (*root)->left = NULL; (*root)->right = NULL; } else{ if((*root)->left != NULL && (*root)->right == NULL) add(x,&((*root)->right)); else add(x,&(*root)->left); } }