Visual Basic 2008 Programming: Business Applications with a Design Perspective
Chapter 1 Chapter 2 Chapter 3 Chapter 4 Chapter 5 Chapter 6 Chapter 7 Chapter 8 Chapter 9
Chapter 10 Chapter 11 Chapter 12 Chapter 13 Chapter 14 Appendix A Appendix B Appendix C Home
Loading
Last change: February 13 2016 18:48:19.

 Chapter in PDF

Table of Contents

Appendix C: Sorting and Searching
Last change: February 13 2016 18:48:22.
<<PreviousNext>>

C.5 Comparison of Performance

As you can see, some of the algorithms are pretty simple; but others are more involved. In general, if two algorithms give the same performance, you would rather use the simpler one. The additional complexity can be justified only with better performance. So, how do they compare in terms of speed? The following table shows the time used to sort varying number of elements by these algorithms using a Pentium IV 1.4 GHz machine.

Number of Elements Bubble Sort Insertion Sort Shell Sort Quick Sort
4000 0.12017 0.05007 0 0
8000 0.48069 0.17024 0.01001 0
16000 1.92276 0.67096 0.03004 0
32000 7.68104 2.61376 0.07010 0.01001
64000 30.87440 10.63529 0.18026 0.02003

The leftmost column shows the number of integer numbers (generated by the formula given in bubble sort) being sorted. The numbers in the table are time in seconds. Because the numbers are randomly generated, the results can be different if you attempt to replicate the experiments; however, you should be able to make several general observations:

Last change: February 13 2016 18:48:23.
  1. Header for Quick Sort
  2. Comparing Backward
  3. Comparing Forward
  4. The Outer Loop
  5. Sorting the Sub-arrays
  6. Terminating the Procedure
  7. The Better, the Worse
  8. Solving the Paradox
  9. The Stack Space Issue
  10. The Complete Code for Quick Sort
  • C.5 Comparison of Performance
  • C.6 Sequential Search and Binary Search
    1. Improved Sequential Search with Sorted Data
    2. The Binary Search
    3. <<PreviousNext>>