Title: M Pivot Sort Faster Than Quick Sort
1M Pivot Sort Faster Than Quick Sort!
- Presenter James Edmondson
- Mentor Dr. Judy Hankins
- Study funded by MTSU Ronald E McNair Program
2M Pivot Sort Faster than Quick Sort!
Table of Contents
- Introduction .
- Introduction to M Pivot Sort..
- Testing System Specifications
- Testing Ascending Lists
- Testing Descending Lists.
- Testing Random Integer Lists.
- Testing Random String Lists
- Testing Random Class Lists
- Conclusion...
- References..
3 5 7 8 10 12 15 17 19 20
3M Pivot Sort Faster than Quick Sort!
Introduction
- Sorting Algorithms
- Sorting algorithms constitute the core of most
algorithm textbooks. - Most computer programmers still use sorting
algorithms that were developed in the late 1950s
and early 1960s. - O(n log n) is the theoretical lower bound for
comparison based sorting algorithms. - New O(n log n) algorithms have been developed as
late as Multikey Quick Sort in 1997 but are
usually specialized sorts for certain types of
data.
4M Pivot Sort Faster than Quick Sort!
Introduction
- Sorting Algorithms (continued)
- To be accepted into common practice, new sorting
algorithms have to compete with Quick Sort in
speed and usability. - Two other algorithms, Merge Sort and Heap Sort,
are also used widely and should be included in
empirical comparisons.
5M Pivot Sort Faster than Quick Sort!
Introduction M Pivot Sort
- M Pivot Sort
- Based on partitioning principle in Quick Sort.
- Applies the Strong Law of Large Numbers to
produce better sampling than Quick Sort. - Handles duplicates in linear time (Quick Sort
goes into polynomial time without three way
partitioning.) - Performs on average in O(n log n) time.
- Has a better worst case scenario (roughly half)
than Quick Sort.
6M Pivot Sort Faster than Quick Sort!
Introduction M Pivot Sort
- M Pivot Sort (continued)
- Performs more targeted moves than Quick Sort
(results in less moves) - Performs slightly more data comparisons than
Quick Sort but far less than Heap Sort. - Performs less recursion than Quick Sort or Merge
Sort. - May perform runtime changes to correct polynomial
time O(n2) performance by changing the number
of pivots (3-7).
7M Pivot Sort Faster than Quick Sort!
Testing System Specifications
- System Specifications for Testing
- Quad Xeon, 2 GBs of RAM, Intel Architecture.
- Windows 2003 Server Standard Edition.
- Visual C command prompt based.
- Random Integer Generator designed by Andy Thomas.
- Random string generator produces 4-19 character
random ANSI C strings. - Random class generator produces 4 7-17 character
random ANSI C strings, one of which is the
sorting key. - Ascending and descending lists are integer based.
- Ten different sets of data ran for each algorithm
for each type of test. Mean average taken for
stats generated here.
8M Pivot Sort Faster than Quick Sort!
Testing Ascending Lists
Tests on list of 100 million ascending integers
Units expressed in 100 million operations, ie
Merge Sort performed 66.83 100 million
operations, or 6,683,000,000 total operations.
9M Pivot Sort Faster than Quick Sort!
Testing Ascending Lists
Tests on list of 100 million ascending integers
10M Pivot Sort Faster than Quick Sort!
Testing Descending Lists
Tests on list of 100 million descending integers
Units expressed in 100 million operations, ie
Merge Sort performed 66.83 100 million
operations, or 6,683,000,000 total operations.
11M Pivot Sort Faster than Quick Sort!
Testing Descending Lists
Tests on list of 100 million descending integers
12M Pivot Sort Faster than Quick Sort!
Testing Random Integers
Tests on list of 100 million random integers
Units expressed in 100 million operations, ie
Merge Sort performed 78.65 100 million
operations, or 7,650,000,000 total operations.
13M Pivot Sort Faster than Quick Sort!
Testing Random Integers
Tests on list of 100 million random integers
14M Pivot Sort Faster than Quick Sort!
Testing Random Integers
Test on list of 100 million random integers
(200,000 possible values duplicate records
present)
Shows Quick Sorts performance on duplicates vs.
Pivot Sort. Source is M Pivot Sort Replacing
Quick Sort.
15M Pivot Sort Faster than Quick Sort!
Testing Random Strings
Tests on list of 10 million random strings
Units expressed in 10 million operations, ie
Merge Sort performed 68.65 10 million operations,
or 686,500,000 total operations.
16M Pivot Sort Faster than Quick Sort!
Testing Random Strings
Tests on list of 10 million random strings
17M Pivot Sort Faster than Quick Sort!
Testing Random Classes
Tests on list of one million random classes
Units expressed in 1 million operations, ie Merge
Sort performed 58.58 one million operations, or
58,580,000 total operations.
18M Pivot Sort Faster than Quick Sort!
Testing Random Classes
Tests on list of one million random classes
19M Pivot Sort Faster than Quick Sort!
Conclusion
- Conclusion
- M Pivot Sort meets or beats the time taken by
Quick Sort for sorts on contiguous lists
(arrays). - M Pivot Sort performs favorably on sorting
presorted and descending lists (common database
operations.) - M Pivot Sort performs less moves and less total
operations than Quick Sort, Heap Sort, and Merge
Sort. - M Pivot Sort is an ideal candidate for general
purpose sorting libraries for varied or singular
data types.
20M Pivot Sort Faster than Quick Sort!
References
- References
- 1 Bentley, Jon L. The trouble with qsort.
UNIX Review. 10.2 (1992) 85-90. - 2 Bentley, Jon L. Software Exploratorium
history of a Heapsort. UNIX Review. 10.8
(1992) 71-77. - 3 Cormen, Thomas, et al. Introduction to
Algorithms. 2nd ed. Massachusetts MIT Press,
2001. - 4Edmondson, James. M Pivot Sort Replacing
Quick Sort. Proceedings of the 2005
International Conference on Algorithmic
Mathematics and Computer Science (2005) 47-53. - 5 Kruse, Robert, et al. Data Structures
Program Design in C . 2nd ed. New Jersey
Prentice Hall, 1997. 335. - 6 McClave, James T. and Terry Sincich. A First
Course in Statistics Annotated Instructors
Edition. 8th ed. New Jersey Prentice Hall,
2003. 224, 277-308. - 7 Sedgewick, Robert and Jon Bentley.
Quicksort is Optimal. Knuthfest, Stanford
University, Stanford. January 2002. - 8 Sedgewick, Robert. Algorithms in Java. 3rd
ed. Boston Addison-Wesley, 2003. - 9 Thomas, Andy. Randomal64 Pseudo Random
Number Generator. Generation5.org. 20 April
2001. 6 Feb. 2005 lthttp//www.generation5.org/cont
ent/2001/ga01.aspgt.