Skip to main content
ICT
Lesson AB26 - QuickSort
 
Main Previous Next
Title Page >  
Summary >  
Lesson A1 >  
Lesson A2 >  
Lesson A3 >  
Lesson A4 >  
Lesson A5 >  
Lesson A6 >  
Lesson A7 >  
Lesson A8 >  
Lesson A9 >  
Lesson A10 >  
Lesson A11 >  
Lesson A12 >  
Lesson A13 >  
Lesson A14 >  
Lesson A15 >  
Lesson A16 >  
Lesson A17 >  
Lesson A18 >  
Lesson A19 >  
Lesson A20 >  
Lesson A21 >  
Lesson A22 >  
Lesson AB23 >  
Lesson AB24 >  
Lesson AB25 >  
Lesson AB26 >  
Lesson AB27 >  
Lesson AB28 >  
Lesson AB29 >  
Lesson AB30 >  
Lesson AB31 >  
Lesson AB32 >  
Lesson AB33 >  
Vocabulary >  
 

B. Order of QuickSort page 4 of 6

  1. Determining the order of QuickSort, O (N* log2N), is a difficult process. The best way to understand it is to imagine a hypothetical situation in which each call of quickSort results in sublists of the same size. Let’s try a size of 128, because it is a power of 2.

  2. If a list has 128 elements, the number of calls of quickSort required to move a value into its correct spot is log2128, which equals 7 steps. Dividing the list in half gives us the log2N aspect of QuickSort.

  3. But we need to do this to 128 numbers, so the approximate number of steps to sort 128 numbers will be 128 * log2128. A general expression of the order of QuickSort will be O(N * log2N). An O(N * log2N) algorithm is a more specific designation of the broader category called O(N * log N).

  4. A graph of an O(N* log2N) algorithm is close to a linear algorithm, for large values of N. The log2N number of steps grows very slowly, making QuickSort a dramatic improvement over the O(N2) sorts.

 

Main Previous Next
Contact
 © ICT 2006, All Rights Reserved.