Shell Sort Algorithm - Javascript

Subscribe to my newsletter and never miss my upcoming articles

Shell sort is an in-place comparison based sorting algorithm. It is generalization of insertion sort. It sorts elements which are far apart from each other.

In insertion sort, we do comparison between only adjacent elements, but shell sort avoids comparing adjacent elements until last steps. insertion sort kicks in exactly in the last steps of shell sort.

Shell sort is nothing else but an improvement of insertion sort algorithm. The improvement is in the comparison and swap of far apart elements.

Shell sort uses a sequence that can be referred as increment sequence. In general, the algorithm breaks an original array into smaller subarrays and then each of those subarrays is sorted using Insertion sort.

This a highly efficient algorithm.

See the live example here:

Thanks for reading this article.

Let's Connect.

Next article will be: Merge Sort Algorithm

No Comments Yet