**Sorting Algorithm Tutorials - Herong's Tutorial Examples** - Version 6.01, by Dr. Herong Yang

Shell Sort - Performance

This section provides a tutorial on how to measure the performance of the Shell Sort algorithm. My first Java implementation of Shell Sort is performing somewhere between O(N*Log2(N) and O(N*N) order levels.

Now let's see how my Java implementation of the Shell Sort algorithm performs. I tried this implementation with my SortTest.java under JDK 1.3.1. Here are the results:

Array size: 10000 Average sorting time: 25 milliseconds Number of tests: 1000 Performance: 2.5 O(N) nanoseconds Performance: 0.18814374728998823 O(N*Log2(N)) nanoseconds Performance: 2.5E-4 O(N*N) nanoseconds Array size: 20000 Average sorting time: 81 milliseconds Number of tests: 1000 Performance: 4.05 O(N) nanoseconds Performance: 0.28346035337307884 O(N*Log2(N)) nanoseconds Performance: 2.025E-4 O(N*N) nanoseconds Array size: 30000 Average sorting time: 148 milliseconds Number of tests: 1000 Performance: 4.933333333333334 O(N) nanoseconds Performance: 0.3317045099854675 O(N*Log2(N)) nanoseconds Performance: 1.6444444444444444E-4 O(N*N) nanoseconds

As you can see, the performance of this Shell Sort is much better than Insertion sort. But it is still not as good as Quicksort.

*Last update: 2011.*

Table of Contents

Introduction of Sorting Algorithms

Java API for Sorting Algorithms

Insertion Sort Algorithm and Implementation

Selection Sort Algorithm and Implementation

Bubble Sort Algorithm and Implementation

Quicksort Algorithm and Implementation

Merge Sort Algorithm and Implementation

Heap Sort Algorithm and Implementation

►Shell Sort Algorithm and Implementation

Shell Sort - Algorithm Introduction

Shell Sort - Java Implementation

Shell Sort - Implementation Improvements