title: sorting a linkedlist using quick sort in C
body: <p>I am using linux and trying to write the program in C for sorting linked list elements using quick sort. here is my code.  </p>
  
  <pre><code>struct node {
      int data;
      struct node *link;
      struct node *plink;
  };
  
  struct node *first=NULL, *last=NULL;
  
  void swap(struct node* a, struct node* b) {
      int temp;
      temp = a-&gt;data;
      a-&gt;data = b-&gt;data;
      b-&gt;data = temp;
  }
  
  void qsort(struct node *low, struct node *high) {
      if(low==NULL || high==NULL || low == high || low-&gt;plink == high)
          return ;
  
      struct node *pivot=low, *tmp=low-&gt;link;
  
      while(tmp != high-&gt;link) {
          if(tmp-&gt;data &lt; low-&gt;data) {
              swap(pivot-&gt;link, tmp);
              pivot = pivot-&gt;link;
          }
          tmp = tmp-&gt;link;
      }
  
      swap(low, pivot);
      qsort(low, pivot-&gt;plink);
      qsort(pivot-&gt;link, high);
  }
  </code></pre>
  
  <p>It's working fine for a small text file but not working for a file of 1.7M. Please tell me what I need to add.</p>
  
  <p>Thanks in advance.</p>