Quick Sort

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
  int x = array[top];
      int i = top - 1;
      int j = bottom + 1;
      int temp;
      do
      {
            do      
            {
                   j - -;
            }while (x >array[j]);

           do  
          {
                  i++;
           } while (x <array[i]);

           if (i < j)
          { 
                  temp = array[i];    
                  array[i] = array[j];
                  array[j] = temp;
          }
      }while (i < j);     
      return j;

}


this is a quicksort partitioning program that ive been trying to understand however. To me it seems that I and j are pointing at non existing elements?

considering in my eyes

Top is meant to be array [0] and bottom[last aray]

I think I have definetly viewed this in the wrong way probably didn't understand this.



this


// top = subscript of beginning of array
// bottom = subscript of end of array
Can someone explain if possible
Topic archived. No new replies allowed.