
UNIVERSITY OF CINCINNATI Date: 8/21/2007 I, Spencer Morgan, hereby submit this work as part of the requirements for the degree of: Master of Science in: Computer Science It is entitled: Reduced Assignment Sorting This work and its defense approved by: Chair: John Franco Fred Annexstein Jerome Paul Dieter Schmidt Reduced Assignment Sorting A thesis submitted to the University of Cincinnati in partial fulfillment of the requirements for the degree of Master of Science from the Department of Computer Science of the College of Engineering Successfully defended August 21, 2007 by Spencer Morgan BS Information Technology, University of Cincinnati, 1997 [email protected] 513-251-6790 Committee Chair: Dr. John Franco Dr. Fred Annexstein Dr. Jerome Paul Dr. Dieter Schmidt Abstract: A new comparison-based sorting algorithm is presented that can reorder the elements in the fewest possible assignments (which is never greater than 3n/2), with a comparison complexity of O(nlogn) 1 Copyright 2007 Spencer Morgan 2 Dedication I dedicate this work to the late Dr. Marceline A. Barron, who motivated, inspired, and encouraged me throughout my life. If it were not for her assistance I might not have pursued a career with computers. Acknowledgements First, I thank Dr. Dieter Schmidt who planted the seed of inspiration in that algorithms course many years ago. The ideas which germinated, and were cultivated after I left academia, are now, upon my return, bearing fruit as this thesis. I would like to thank the Department of Computer Science for the University Graduate Scholarship which allowed me to focus on my studies. I thank my advisor, Dr. John Franco, for his patience and guidance through what turned out to be a more arduous task than I had originally envisioned. I want to thank my committee for taking the time to read my thesis and listen to my defense. Dr. Naoyuki Tokuda should be thanked for providing me with his paper “An Improved Shellsort.” And for proofreading help and criticism I want to thank Narasiman Villori, Bill Nicholson, Manohar Balapa, Gardner Coughlen, and, last but not least, Betty Kaiser. 3 Table of Contents Abstract:............................................................................................................................. 1 Copyright 2007 Spencer Morgan................................................................................. 2 Dedication .......................................................................................................................... 3 Acknowledgements............................................................................................................ 3 Table of Contents .............................................................................................................. 4 Table of Figures................................................................................................................. 6 Table of Tables .................................................................................................................. 6 1. Introduction ............................................................................................................... 8 1.1. Notable Algorithms ........................................................................................... 9 1.1.1. Merge Sort ............................................................................................... 10 1.1.2. Insertion Sort........................................................................................... 10 1.1.3. Shell Sort.................................................................................................. 11 1.1.4. Quick Sort................................................................................................ 11 1.1.5. Selection Sort ........................................................................................... 12 1.1.6. Heap Sort ................................................................................................. 12 1.2. Theoretical Bounds ......................................................................................... 13 2. Theoretical Lower Bounds for Assignments......................................................... 14 2.1. Average Lower Bound of Assignments ......................................................... 16 2.2. Worst-Case Lower Bound of Assignments ................................................... 17 3. Reduced Assignment Sort (RAS) Algorithm ........................................................ 18 3.1. Stage 1 – Finding an Ordering....................................................................... 19 3.2. Stage 2 – Mapping each Element................................................................... 20 3.2.1. Unstable Assignments ............................................................................. 22 3.2.2. Optimal Assignments .............................................................................. 23 3.3. Stage 3 – Moving the Elements ...................................................................... 24 3.4. Storage Overhead............................................................................................ 25 3.5. Complexity ....................................................................................................... 25 4. Analyzing Sorts........................................................................................................ 26 4.1. Analyzing Assignments................................................................................... 26 4.1.1. Random Data........................................................................................... 26 4.1.2. Special Data ............................................................................................. 27 4.2. Analyzing Comparisons.................................................................................. 28 4.2.1. Random Data........................................................................................... 28 4.2.2. Special Data ............................................................................................. 29 4.3. Assignments and Comparisons ...................................................................... 29 4.4. Analyzing Time................................................................................................ 30 4.5. Limitations ....................................................................................................... 31 5. Future Enhancements............................................................................................. 32 5.1. Optimize Comparisons ................................................................................... 32 5.2. Avoid Comparisons......................................................................................... 32 5.3. Reimplement Problems as a Sort................................................................... 32 5.3.1. Defragmentation...................................................................................... 33 5.3.2. Inventory Management........................................................................... 33 6. Summary.................................................................................................................. 34 4 Appendix A - Sort Tester................................................................................................ 35 Informational Counting.............................................................................................. 36 Display.......................................................................................................................... 36 DataSet ......................................................................................................................... 37 SortTypes ..................................................................................................................... 39 Bubble Sort .............................................................................................................. 39 Insertion Sort........................................................................................................... 39 SMInsert................................................................................................................... 40 Bingo Sort................................................................................................................. 40 J Sort......................................................................................................................... 41 Shell Sort.................................................................................................................. 41 Heap Sort ................................................................................................................. 44 Merge Sort ............................................................................................................... 44 Quick Sort................................................................................................................ 45 RAS – Reduced Assignment Sort........................................................................... 47 RAS16 – 16 bit Reduced Assignment Sort............................................................ 50 Appendix B – Sorts.mdb database of results................................................................ 51 Table SortsCsv............................................................................................................. 51 Form frmAddNew......................................................................................................
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages238 Page
-
File Size-