M Pivot Sort – Faster Than Quick Sort! Presenter: James Edmondson Mentor: Dr. Judy Hankins Study funded by MTSU Ronald E McNair Program

M 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…………………………………………….. 11/27/2011

3 5 7

8 10 12

15 17 19

20 2

M 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. 11/27/2011

3

M 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.

11/27/2011

4

M 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.

11/27/2011

5

M 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). 11/27/2011

6

M 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. 11/27/2011

7

M Pivot Sort – Faster than Quick Sort!

Testing: Ascending Lists

* Tests on list of 100 million ascending integers

Asce nding List - Total Ope rations in N Units

Quick Sort (CM)

65.08

Quick Sort (MOT)

64.09

Pivot Sort

40.73

Merge Sort

66.83

Heap Sort 0.00

130.77 20.00

40.00

60.00

80.00

100.00

120.00

140.00

Units expressed in 100 million operations, ie Merge Sort performed 66.83 100 million operations, or 6,683,000,000 total operations. 11/27/2011

8

M Pivot Sort – Faster than Quick Sort!

Testing: Ascending Lists

* Tests on list of 100 million ascending integers

Ascending List - Sorting Time in Seconds Quick Sort (CM)

18

Quick Sort (MOT)

15

Pivot Sort

16

Merge Sort

34

Heap Sort

33 0

11/27/2011

5

10

15

20

25

30

35

40

9

M Pivot Sort – Faster than Quick Sort!

Testing: Descending Lists

* Tests on list of 100 million descending integers

Descending List - Total Operations in N Units Quick Sort (CM)

68.10

Quick Sort (MOT)

65.45

Pivot Sort

56.06

Merge Sort

66.46

Heap Sort 0.00

124.25 20.00

40.00

60.00

80.00

100.00

120.00

140.00

Units expressed in 100 million operations, ie Merge Sort performed 66.83 100 million operations, or 6,683,000,000 total operations. 11/27/2011

10

M Pivot Sort – Faster than Quick Sort!

Testing: Descending Lists

* Tests on list of 100 million descending integers

Descending List - Sorting Time in Seconds 20

Quick Sort (CM) 17

Quick Sort (MOT) Pivot Sort

18

Merge Sort

32

Heap Sort

35 0

11/27/2011

5

10

15

20

25

30

35

40

11

M Pivot Sort – Faster than Quick Sort!

Testing: Random Integers

* Tests on list of 100 million random integers

Random Integer List - Total Operations in N Units Quick Sort (CM)

88.18

Quick Sort (MOT)

75.56

Pivot Sort

66.84 78.65

Merge Sort

127.28

Heap Sort 0.00

20.00

40.00

60.00

80.00

100.00 120.00 140.00

Units expressed in 100 million operations, ie Merge Sort performed 78.65 100 million operations, or 7,650,000,000 total operations. 11/27/2011

12

M Pivot Sort – Faster than Quick Sort!

Testing: Random Integers

* Tests on list of 100 million random integers

Random Integer List - Sorting Time in Seconds Quick Sort (CM)

33

Quick Sort (MOT)

27

Pivot Sort

27

Merge Sort

49 156

Heap Sort 0

11/27/2011

50

100

150

200

13

M Pivot Sort – Faster than Quick Sort!

Testing: Random Integers

* Test on list of 100 million random integers (200,000 possible values – duplicate records present) Time in Seconds - 100 Million Random Integers (0-200,000 possible values) 160

148

140 120

101

100 80 60

48

40 19

20 0 Heap Sort

Merge Sort

Pivot Sort

Quick Sort

Figure 8

Shows Quick Sort’s performance on duplicates vs. Pivot Sort. Source is M Pivot Sort – Replacing Quick Sort. 11/27/2011

14

M Pivot Sort – Faster than Quick Sort!

Testing: Random Strings

* Tests on list of 10 million random strings

Random String List - Total Operations in N Units Quick Sort (CM)

76.72

Quick Sort (MOT)

65.83

Pivot Sort

58.70

Merge Sort

68.65 110.61

Heap Sort 0.00

20.00

40.00

60.00

80.00

100.00

120.00

Units expressed in 10 million operations, ie Merge Sort performed 68.65 10 million operations, or 686,500,000 total operations. 11/27/2011

15

M Pivot Sort – Faster than Quick Sort!

Testing: Random Strings

* Tests on list of 10 million random strings

Random String List - Sorting Time in Seconds Quick Sort (CM)

61

Quick Sort (MOT)

54

Pivot Sort

43

Merge Sort

80 116

Heap Sort 0

11/27/2011

20

40

60

80

100

120

140

16

M Pivot Sort – Faster than Quick Sort!

Testing: Random Classes

* Tests on list of one million random classes

Random Class List - Total Operations in N Units Quick Sort (CM)

65.60

Quick Sort (MOT)

56.39

Pivot Sort

50.15

Merge Sort

58.58 93.94

Heap Sort 0.00

20.00

40.00

60.00

80.00

100.00

Units expressed in 1 million operations, ie Merge Sort performed 58.58 one million operations, or 58,580,000 total operations. 11/27/2011

17

M Pivot Sort – Faster than Quick Sort!

Testing: Random Classes

* Tests on list of one million random classes

Random Class List - Sorting Time in Seconds Quick Sort (CM)

18

Quick Sort (MOT)

17

Pivot Sort

12

Merge Sort

16 28

Heap Sort 0

11/27/2011

5

10

15

20

25

30

18

M 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. 11/27/2011

19

M 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. – [4]Edmondson, 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 Instructor’s 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 .

11/27/2011

20

M Pivot Sort – Faster Than Quick Sort!

Nov 27, 2011 - Study funded by MTSU Ronald E McNair Program .... International Conference on Algorithmic Mathematics and Computer Science (2005): ...

335KB Sizes 2 Downloads 79 Views

Recommend Documents

M Pivot Sort – Replacing Quick Sort
Computer Science Department ..... Time in Seconds - 100 Million Random Integers. (0-200,000 possible values). 148. 48. 19. 101. 0. 20. 40 ... arrays of classes or strings, cases that generally feature more work being done on a move than a.

Insertion Sort
What's the worst case runtime of insertion sort? What's the best case runtime of insertion sort? ○. Lin. Page 11. Page 12. Bubble. Sort. O. Ω. Θ. Selection. Sort.

Selection Sort
for i = 0 to n - 2 min = i for j = i + 1 to n - 1 if array[j] < array[min] min = j; if min != i swap array[min] and array[i]. Page 10. What's the best case runtime of selection ...

Merge Sort
On input of n elements: If n < 2. Return. Else. Sort left half of elements. Sort right half of elements. Merge sorted halves. Page 3. 3. 2. 5. 4. 6. 2. 5. 3. 4. 6. 1. 1. Page 4. Halve until each subarray is size 1. 4. 3. 2. 5. 4. 6. 2. 5. 3. 4. 6. 6.

Merge Sort - CS50 CDN
Data stored in memory has both a value and a location. • Pointers contain the memory address of some piece of data. • * pointer contains address to a ...

Merge Sort - CS50 CDN
Data stored in memory has both a value and a location. • Pointers contain the memory address of some piece of data. • * pointer contains address to a ...

Connotation Sort Handout.pdf
Connotation Sort Handout.pdf. Connotation Sort Handout.pdf. Open. Extract. Open with. Sign In. Main menu. There was a problem previewing this document.

Gummy Bear Sort Sheet.pdf
Gummy Bear sort. red yellow. orange. green white. Whoops! There was a problem loading this page. Whoops! There was a problem previewing this document.

ANIMAL SORT - PET OR WILD.pdf
www.filefolderfarm.com. Page 3 of 4. ANIMAL SORT - PET OR WILD.pdf. ANIMAL SORT - PET OR WILD.pdf. Open. Extract. Open with. Sign In. Main menu.

The Two-Pocket JetScanTM - Pro Sort
Software and currency upgrades are available through flashcard technology. Speed: 1,000 notes per minute ... Frequency is 50/60Hz. Customer must provide an electrical supply ... machine warranty or preventative maintenance agreement.).

Spring Synonym Sort Freebie.pdf
resources at my TPT store: 2nd Grade Snickerdoodles. You can follow my blog at. http://2ndgradesnickerdoodles.blogspot.com/. Please email me if you have ...

The Two-Pocket JetScanTM - Pro Sort
Illuminated, touch screen technology greatly enhances operation. The screen changes for each ... and patented technologies challenge .... grounded outlet.

heap sort example pdf
Sign in. Loading… Whoops! There was a problem loading more pages. Whoops! There was a problem previewing this document. Retrying... Download. Connect ...

SOGI Card Sort Activity.pdf
Page 1 of 4. Ally Asexual. Fag/Faggot Gay. Gender Identity Gender Transition. GSA. (Gay-Straight Alliance) Heterosexism. Page 1 of 4 ...

Excerpt from The Big Sort by Bill Bishop.pdf
Page 1 of 13. 1. Excerpt from The Big Sort. By Bill Bishop. INTRODUCTION. MOST OF US MAKE AT LEAST THREE IMPORTANT DECISIONS IN OUR LIVES: ...

insertion sort in data structure pdf
Sign in. Loading… Whoops! There was a problem loading more pages. Retrying... Whoops! There was a problem previewing this document. Retrying.

Not So Sort Introduction to Latex 2e
2.4.4 Degree Symbol (◦) . . . . . . . . . . . . . . . . . . . . 22 ..... word processors, such as MS Word or Corel WordPerfect, take. With these ..... abbreviation. LATEX tries to ...

Constitution Card sort Matrix and questions.doc.pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. Constitution ...

Robust Warehouse Flooring Is Needed For Any Sort of Property.pdf ...
area of expertise, the polished concrete flooring in Melbourne they offer is also very. highly regarded in the market. Wait no more to get in touch with them and let them work best for all such needed. outcomes. Go over the Internet and you will be g

Word Sort - Jim Thorpe's Bright Path.pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. Word Sort - Jim ...

Sort-Cut: A Pareto-Optimal and Semi-Truthful ... - Andrew.cmu.edu
We propose Sort-Cut, a mechanism which does the next best ... (GSP) auction implemented for sponsored search ads at Google. Perhaps even ... of Sort-Cut. While earlier work on the problem led to mechanisms that leave some items unallocated [Borgs et

Faster than possible.key
App Code. en_US. Safari 2.0.x. App Code. fr_FR … IE 6. App Code. en_UK … Opera 9. App Code. fr_CA ... When Scripting, Abstractions Cost Ya. • Equivalent ...

Userhelp site - card sort - Original UserHelp -
Managing your site. Setting up AdvancedWorkflow. Web content best practices. Blogs. Forms. Forums. Working with multiple sites. Working with translation.

Faster than possible.key
A modest goal: the best attainable performance ... App Code. en_US. Safari 2.0.x. App Code. fr_FR … IE 6. App Code. en_UK ... Particularly horrible for mobile.