title: binary search tree using rand
body: <p>i am trying to create a binary search tree with 50 random variables, i wrote a code but the random variables are not being declared..please help me out </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstdlib&gt;
  using namespace std;
  </code></pre>
  
  <p>//creating a class node which contains value,rvalue which stores the value pointed by  rlink and  lvalue which stores the value pointed by  llink</p>
  
  <pre><code>class node
  
  
  {
  private:
  int value;
  int rvalue;
  int lvalue;
  node *rlink;
  node *llink;
  
  public:
  
  void insertnode(node*,int);
  node *create(node*,int); 
  
  };
  
  
  
  void node::insertnode(node *h,int k)
  
  {
  
  h=new node;
  h-&gt;value=k;
  h-&gt;rlink=NULL;
  h-&gt;llink=NULL;
  h-&gt;rvalue=0;
  h-&gt;lvalue=0;
  
  }
  
  
  node *node::create(node*root, int i)
  
  {
  
  int A[i];
  for(int j=0; j&lt;i; j++) {
      A[j]=rand()%1000;  //stores random values in array
      cout&lt;&lt;A[j];
  
  }
  node *k;
  node *h;
  insertnode(root, A[0]);
  
  cout&lt;&lt;h-&gt;value;
  
  for (int j=1; j&lt;i; j++) {
      if(A[j]&lt;h-&gt;value){
          if(h-&gt;llink==NULL) {
              insertnode(k, A[j]);
              h-&gt;lvalue=k-&gt;value;
  
          }
          h-&gt;llink=k;
      }
      else if(A[j]&gt;h-&gt;value)
      {
          if(h-&gt;rlink==NULL) {
              insertnode(k, A[j]);
              h-&gt;rvalue=k-&gt;value;
  
          }
          h-&gt;rlink=k;
  
      }
  
  
  } 
  
  return root;
  
  
  }
  
  
  int main()
  
  {
  
  
  int i;
  cout&lt;&lt;"enter the number of elements in a matix";
  cin&gt;&gt;i;
  node s;
  node *h;
  h=s.create(h,i);
  
  }
  </code></pre>