0% found this document useful (0 votes)
2 views2 pages

Java Shell Sort Implementation Guide

Uploaded by

melvin.nv1975
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Java Shell Sort Implementation Guide

Uploaded by

melvin.nv1975
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

// Shell sort in Java programming

import [Link];
class ShellSort
{
void shellSort(int array[], int n) {
for (int interval = n / 2; interval > 0; interval /= 2)
{
for (int i = interval; i < n; i += 1)
{
int temp = array[i];
int j;
for (j = i; j >= interval && array[j - interval] >
temp; j -=
interval)
{
array[j] = array[j - interval];
}
array[j] = temp;
}
}
}
public static void main(String args[])
{
int[] data = { 9, 8, 3, 7, 5, 6, 4, 1 };
int size = [Link];
ShellSort ss = new ShellSort();
[Link](data, size);
[Link]("Sorted Array in Ascending Order: ");
[Link]([Link](data));
}
}

You might also like