title: How can I find the next node higher value than a selected number in a Binary Search Tree in C?
body: <p>For example: If my Tree data have the nodes with following values = (10, 20, 30, 40, 50, 60);</p>
  <p>And if 45 is selected, then I must return the node with the next hight value. (if 45, then 50).</p>
  <p>Must return NULL if there's no higher value.</p>
  <p>Code:</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  struct Tree {
      int x;
      struct Tree *left, *right;
  };
  typedef struct Tree Tree;
  
  Tree * create_empty_tree() {
     return NULL;
  }
  
  Tree * insert(Tree *t, int x) {
      if (t == NULL) {
          t = (Tree *) malloc(sizeof(Tree));
          t-&gt;x= x;
          t-&gt;left = NULL;
          t-&gt;right = NULL;
      } else if (x &lt; t-&gt;x) {
          t-&gt;left = insert(t-&gt;left, x);
      } else {
          t-&gt;right = insert(t-&gt;right, x);
      }
  }
  
  void print_in_order(Tree *arv) {
     if (arv != NULL) {
        print_in_order(arv-&gt;left);
        printf(&quot;%d, &quot;, arv-&gt;x);
        print_in_order(arv-&gt;right);
     }
  }
  
  Tree * find_node_higher_than_x(Tree *t, int x) {
       //toDo
  }
  
  int main() {
      Tree *t = create_empty_tree();
      t = insert(t, 2);
      t = insert(t, 8);
      t = insert(t, 10);
      t = insert(t, 4);
      t = insert(t, 6);
      t = insert(t, 7);
      t = insert(t, 1);
      
      print_in_order(t);
      
      Tree *node = find_node_higher_than_x(t, 5); //Must return node with x == 6
  }
  </code></pre>
  <p>There's a way to make it?</p>