STUDY & ANALYSIS OF
SORTING METHODS
By
Aditya Y. Vichare
Department Of Mathematics
CONTENTS
1. System Information
2. Algorithm Analysis
3. Sorting Algorithm
4. Observations
5. Conclusion
6. Credits And Bibliography
SYSTEM INFORMATION
▸ Operating System : Linux
▸ Distro : Ubuntu 16.0
▸ Type : 64 - Bit
▸ Processor : Intel® Core™2 CPU 4400 @ 2.00GHz × 2
▸ Chipset : Intel® G41
▸ RAM : 2GB
▸ Avg. Temperature of Cores : 55-75 C
SOFTWARE AND MODULE INFORMATION
▸ Language : Python 3.4
▸ Modules : Matplotlib , Time
ALGORITHM ANALYSIS
▸A Priori Analysis −
● This is a theoretical analysis of an algorithm.
●Efficiency of an algorithm is measured by assuming that all other
factors,
● e.g. processor speed, are constant and have no effect on the
implementation.
▸A Posterior Analysis −
●This is an empirical analysis of an algorithm.
●The selected algorithm is implemented using programming language.
ALGORITHM COMPLEXITY
▸ Time Complexity
Amount of time required by the algorithm to run to completion.
▸ Space Complexity
Amount of memory space required by the algorithm in its life cycle.
EXPERIMENTAL STUDIES
▸ Study the runtime of algorithm
▸ Executing it on various test inputs
▸ Recording of time spent during each execution.
ASYMPTOTIC ANALYSIS
Defining the Mathematical boundaries of the function.
SELECTED SORTING METHODS
Merge
Sort
Sorting
Methods
Quick
Sort
Shell
Sort
Insertion
Sort
Bubble Sort
Selection
Sort
BUBBLE SORT
▸ Repeatedly pass through the array
▸ Swaps adjacent elements that are out of order
INSERTION SORT
▸ Assume first element as
sorted.
▸ Maintain sorted sub list by
adding element.
▸ Insert each new item in
sub list w.r.t. value
▹Find the smallest / largest
element in the array
▹Exchange it with the
element in the first position /
last position
▹Find the second smallest /
largest element and
exchange it with the element
in the second position
▹Continue until the array is
sorted
SELECTION SORT
▸ Divide list into smaller sub list of equal interval h
▸ Sort them by Insertion Sort
▸ Repeat until whole list get sorted
SHELL SORT
MERGE SORT
▸ If it is only one element, then its already sorted.
▸ Divide the list recursively into two halves until it can no more get
divided
▸ Merge the smaller list into sorted order
QUICK SORT
▸ Make the right most index value pivot
▸ Partition the array using pivot value
▸ Quicksort(left partition)
▸ Quicksort(Right partition)
OBSERVATIONS
OF EXPERIMENTAL ANALYSIS
3 Categories
2,214 Total values
6 Algorithms
PROPERTIES :
COMPARISON TABLE OF TIME COMPLEXITY
USING ASYMPTOTIC ANALYSIS
TIME
SORTING METHODS AVERAGE CASE BEST CASE WORST CASE
Bubble Sort O(n^2) O(n^2) O(n^2)
Selection Sort O(n^2) O(n^2) O(n^2)
Insertion Sort O(n^2) O(n) O(n^2)
Shell Sort O(n*log n) O(n*log^2 n) O(n*log^2 n)
Merge Sort O(n*log n) O(n*log n) O(n*log n)
Quick Sort O(n*log n) O(n*log n) O(n^2)
CATEGORY : 1- 100
▸ Almost Double time taken by
Bubble Sort than rest.
▸ Selection Sort & Insertion Sort
Shows same Behavior.
Bubble Sort, Selection Sort , Insertion Sort
Selection Sort,
Insertion Sort
Bubble Sort
CATEGORY : 1- 100 Quick Sort, Merge Sort , Shell Sort
Merge Sort
Quick Sort
CATEGORY : 1- 100
▸ Bubble Sort
All Methods
▸ Quick Sort
CATEGORY : 1-1000 Bubble Sort, Selection Sort , Insertion Sort
Selection Sort
Bubble Sort
CATEGORY : 1-1000 Quick Sort, Merge Sort , Shell Sort
Selection Sort
Quick Sort
CATEGORY : 1-1000
Quick Sort
All Methods
Bubble Sort
CATEGORY : 1-10000
Selection Sort
Bubble Sort
Bubble Sort, Selection Sort , Insertion Sort
CATEGORY : 1-10000
Quick Sort
Shell Sort
Quick Sort, Merge Sort , Shell Sort
CATEGORY : 1-10000
Quick Sort, Merge Sort,
Shell Sort
Bubble Sort
All Methods
Bubble Sort, Insertion Sort,
Selection Sort O(n^2)
▸ Bubble sort is least efficient sorting
method among all.
▸ Bubble Sort and Insertion Sort are
for small size array sorting.
▸ Selection sort is more efficient than
other two O(n^2) methods.
CONCLUSION
Shell Sort, Merge Sort, Quick Sort
O(n log n)
▸ Shell Sort is least efficient among
all O(n log n) methods.
▸ Merge Sort requires double
memory allocation.
▸ Quick Sort is most efficient method
among six.
SPEED OF SORTING METHODS IN DESCENDING ORDER
1. Quick Sort
2. Merge Sort
3. Shell Sort
4. Selection Sort
5. Insertion Sort
6. Bubble Sort
CONCLUSION
CREDITS AND BIBLIOGRAPHY
Special thanks to Dr. Rajesh Raut of Department of Mathematics.
▸ Beginning Python, JAMES PAYNE.
▸ Data Structures And Algorithm in Python Goodrich, Michael T., Tamassia.
▸ Geekforgeeks.org
▸ Algolist.com
▸ Matplotlib.org
THANK YOU!
Any questions?
You can contact me at vichareaditya123@gmail.com
By Aditya Y. Vichare.
adityavichare.wordpress.com

Study & Analysis of Sorting Methods

  • 1.
    STUDY & ANALYSISOF SORTING METHODS By Aditya Y. Vichare Department Of Mathematics
  • 2.
    CONTENTS 1. System Information 2.Algorithm Analysis 3. Sorting Algorithm 4. Observations 5. Conclusion 6. Credits And Bibliography
  • 3.
    SYSTEM INFORMATION ▸ OperatingSystem : Linux ▸ Distro : Ubuntu 16.0 ▸ Type : 64 - Bit ▸ Processor : Intel® Core™2 CPU 4400 @ 2.00GHz × 2 ▸ Chipset : Intel® G41 ▸ RAM : 2GB ▸ Avg. Temperature of Cores : 55-75 C SOFTWARE AND MODULE INFORMATION ▸ Language : Python 3.4 ▸ Modules : Matplotlib , Time
  • 4.
    ALGORITHM ANALYSIS ▸A PrioriAnalysis − ● This is a theoretical analysis of an algorithm. ●Efficiency of an algorithm is measured by assuming that all other factors, ● e.g. processor speed, are constant and have no effect on the implementation. ▸A Posterior Analysis − ●This is an empirical analysis of an algorithm. ●The selected algorithm is implemented using programming language.
  • 5.
    ALGORITHM COMPLEXITY ▸ TimeComplexity Amount of time required by the algorithm to run to completion. ▸ Space Complexity Amount of memory space required by the algorithm in its life cycle. EXPERIMENTAL STUDIES ▸ Study the runtime of algorithm ▸ Executing it on various test inputs ▸ Recording of time spent during each execution. ASYMPTOTIC ANALYSIS Defining the Mathematical boundaries of the function.
  • 6.
  • 7.
    BUBBLE SORT ▸ Repeatedlypass through the array ▸ Swaps adjacent elements that are out of order
  • 8.
    INSERTION SORT ▸ Assumefirst element as sorted. ▸ Maintain sorted sub list by adding element. ▸ Insert each new item in sub list w.r.t. value
  • 9.
    ▹Find the smallest/ largest element in the array ▹Exchange it with the element in the first position / last position ▹Find the second smallest / largest element and exchange it with the element in the second position ▹Continue until the array is sorted SELECTION SORT
  • 10.
    ▸ Divide listinto smaller sub list of equal interval h ▸ Sort them by Insertion Sort ▸ Repeat until whole list get sorted SHELL SORT
  • 11.
    MERGE SORT ▸ Ifit is only one element, then its already sorted. ▸ Divide the list recursively into two halves until it can no more get divided ▸ Merge the smaller list into sorted order
  • 12.
    QUICK SORT ▸ Makethe right most index value pivot ▸ Partition the array using pivot value ▸ Quicksort(left partition) ▸ Quicksort(Right partition)
  • 13.
    OBSERVATIONS OF EXPERIMENTAL ANALYSIS 3Categories 2,214 Total values 6 Algorithms PROPERTIES :
  • 14.
    COMPARISON TABLE OFTIME COMPLEXITY USING ASYMPTOTIC ANALYSIS TIME SORTING METHODS AVERAGE CASE BEST CASE WORST CASE Bubble Sort O(n^2) O(n^2) O(n^2) Selection Sort O(n^2) O(n^2) O(n^2) Insertion Sort O(n^2) O(n) O(n^2) Shell Sort O(n*log n) O(n*log^2 n) O(n*log^2 n) Merge Sort O(n*log n) O(n*log n) O(n*log n) Quick Sort O(n*log n) O(n*log n) O(n^2)
  • 15.
    CATEGORY : 1-100 ▸ Almost Double time taken by Bubble Sort than rest. ▸ Selection Sort & Insertion Sort Shows same Behavior. Bubble Sort, Selection Sort , Insertion Sort Selection Sort, Insertion Sort Bubble Sort
  • 16.
    CATEGORY : 1-100 Quick Sort, Merge Sort , Shell Sort Merge Sort Quick Sort
  • 17.
    CATEGORY : 1-100 ▸ Bubble Sort All Methods ▸ Quick Sort
  • 18.
    CATEGORY : 1-1000Bubble Sort, Selection Sort , Insertion Sort Selection Sort Bubble Sort
  • 19.
    CATEGORY : 1-1000Quick Sort, Merge Sort , Shell Sort Selection Sort Quick Sort
  • 20.
    CATEGORY : 1-1000 QuickSort All Methods Bubble Sort
  • 21.
    CATEGORY : 1-10000 SelectionSort Bubble Sort Bubble Sort, Selection Sort , Insertion Sort
  • 22.
    CATEGORY : 1-10000 QuickSort Shell Sort Quick Sort, Merge Sort , Shell Sort
  • 23.
    CATEGORY : 1-10000 QuickSort, Merge Sort, Shell Sort Bubble Sort All Methods
  • 24.
    Bubble Sort, InsertionSort, Selection Sort O(n^2) ▸ Bubble sort is least efficient sorting method among all. ▸ Bubble Sort and Insertion Sort are for small size array sorting. ▸ Selection sort is more efficient than other two O(n^2) methods. CONCLUSION Shell Sort, Merge Sort, Quick Sort O(n log n) ▸ Shell Sort is least efficient among all O(n log n) methods. ▸ Merge Sort requires double memory allocation. ▸ Quick Sort is most efficient method among six.
  • 25.
    SPEED OF SORTINGMETHODS IN DESCENDING ORDER 1. Quick Sort 2. Merge Sort 3. Shell Sort 4. Selection Sort 5. Insertion Sort 6. Bubble Sort CONCLUSION
  • 26.
    CREDITS AND BIBLIOGRAPHY Specialthanks to Dr. Rajesh Raut of Department of Mathematics. ▸ Beginning Python, JAMES PAYNE. ▸ Data Structures And Algorithm in Python Goodrich, Michael T., Tamassia. ▸ Geekforgeeks.org ▸ Algolist.com ▸ Matplotlib.org
  • 27.
    THANK YOU! Any questions? Youcan contact me at vichareaditya123@gmail.com By Aditya Y. Vichare. adityavichare.wordpress.com