title: Implementing Binary search tree using array in C
body: <p>I am trying to implement a binary search tree using a 1-D array. I'm familiar with the fact that the left node will be <code>parent*2+1</code> and right node will be <code>parent*2+2</code>. I am using this concept to write the insertion function here:</p>
  <pre class="lang-c prettyprint-override"><code>int* insert(int tree[], int element){
      int parent=0;
      if(tree[parent]=='\0'){
          tree[parent]=element;
          return tree;
      }
      else{
          if(element&lt;tree[parent]){
              parent=parent*2+1;
              tree[parent]=insert(tree[parent], element);  
          }
          else{
              parent=parent*2+2;
              tree[parent]=insert(tree[parent], element);
          }
      }
      return tree;
  }
  </code></pre>
  <p>However, I'm quite sure this won't work, since I'm passing an element of the array into the <code>insert()</code> function while recursing, when it actually needs an array. I'm not sure how to go about it. Do I replace the return type from <code>int*</code> to <code>int</code>? Any help is appreciated</p>