/** Source code example for "A Practical Introduction to Data Structures and Algorithm Analysis, 3rd Edition (Java)" by Clifford A. Shaffer Copyright 2008-2011 by Clifford A. Shaffer */ /** A JUnit test class for sort algorithms */ import java.io.*; public class SortTest extends junit.framework.TestCase { final static int testsize = 1000; static Integer A[]; static int THRESHOLD = 8; static > void Sort(E[] A) { for (int i=A.length/2; i>2; i/=2) // For each increment for (int j=0; j> void inssort2(E[] A, int start, int incr) { for (int i=start+incr; i=incr)&& (A[j].compareTo(A[j-incr])<0); j-=incr) DSutil.swap(A, j, j-incr); } /** * This method is automatically called once before each test case * method, so that all the variables are cleanly initialized for * each test. */ public void setUp() { A = new Integer[testsize]; for (int i=0; i