import java.awt.*;

public class ShellSort extends ShowSort {
	public static void main(String args[]) {
		ShellSort applet = new ShellSort();
		applet.launch("Shell Sort");
	}

	void doSort() {
		inplace_dir = false;
		inplace_pos = -1;

		for (int k = NUM/2+1; k > 0; k = k/2) {
			partialInsertionSort(array, NUM, k);
		}

		inplace_pos=NUM;
	}

	void partialInsertionSort(int array[], int num, int segments) {
		for (int i=segments; i<NUM; i++) {
			inplace_pos = i;
			
			for (int j=i; j>=segments; j-=segments) {
				compared(j);
				
				if (array[j] >= array[j-segments])
					break;
				
				inplace_pos = i+1;
				
				int temp=array[j];
				array[j]=array[j-segments];
				array[j-segments]=temp;

				swapped(j-segments);
			}
		}
	}
}
