2.2 Sorting algorithm

The sorting algorithm, using the partitioning algorithm, is rather simple. It is listed in listing 2.


Listing 2:quicksort
 
1define sub quicksort 
2  by reference a : array 
3  by value b : integer 
4  by value e : integer 
5  local p : integer
6  p partition(abee)  
7  if b< pthen  
8    quicksort(abp1) 
9  end if 
10  if e>p+1 then  
11    quicksort(ap+1, e
12  end if 
13end define sub

Here is an analysis of the algorithm: