Open In App

Java Program for ShellSort

Last Updated : 10 Jun, 2022
Comments
Improve
Suggest changes
Like Article
Like
Report

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. 

Java




// Java implementation of ShellSort
class ShellSort {
 /* An utility function to print array of size n*/
 static void printArray(int arr[])
 {