Skip to content
This repository has been archived by the owner on Nov 26, 2019. It is now read-only.

Latest commit

 

History

History

Shell_sort

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Shell Sort

ShellSort is mainly a variation of Insertion Sort. In insertion sort, we move elements only one position ahead. When an element has to be moved far ahead, many movements are involved. The idea of shellSort is to allow exchange of far items. In shellSort, we make the array h-sorted for a large value of h. We keep reducing the value of h until it becomes 1. An array is said to be h-sorted if all sublists of every h’th element is sorted.

Input Format

  • Enter the size of array

  • Enter the element in array.

Output Format

  • Prints a single line the array after sorting is.

Sample Input

5
2 4 1 3 5

Sample Output

Array before sorting
2 4 1 3 5
Array after sorting
1 2 3 4 5

Implemented in: