public static long getSortTime(SORT_TYPE type, int[] array) { var attempts = new long[Form1.ATTEMPTS]; for (var j = 0; j < Form1.ATTEMPTS; j++) { switch (type) { case SORT_TYPE.SORT: myStopwatch.Restart(); Array.Sort(array); myStopwatch.Stop(); break; case SORT_TYPE.QUICKSORT: Quicksort<int> q = new Quicksort<int>(); myStopwatch.Restart(); q.QSort(array); myStopwatch.Stop(); break; case SORT_TYPE.HEAPSORT: Heapsort h = new Heapsort(); myStopwatch.Restart(); h.heapSort(array); myStopwatch.Stop(); break; case SORT_TYPE.SHELLSORT: ShellSort<int> s = new ShellSort<int>(); myStopwatch.Restart(); s.Sort(array); myStopwatch.Stop(); break; default: throw new Exception("Unknown error"); } attempts[j] = myStopwatch.ElapsedMilliseconds; } Array.Sort(attempts); return attempts[Form1.ATTEMT_NUMBER_TO_USE-1]; }
public void QuicksortOneElement() { SortList list = new SortList(1); Quicksort.quicksort(list); }
public void PartitionOneElement() { SortList list = new SortList(1); Assert.AreEqual(0, Quicksort.partition(list, 0, 0, 0)); }
public Interface() { InitializeComponent(); experiment = new Experiment(); quickSort = new Quicksort(); }
public void QuickSort_OneElement_IsSorted() { int[] t = { 1 }; Quicksort.Sort(t); Assert.True(IsSorted(t)); }
public void QuickSort_GivenEmpty_RemainsEmpty() { int[] t = {}; Quicksort.Sort(t); Assert.True(t.Length == 0); }
public void QuickSort_GivenNull_ThrowsException() { int[] t = null; Assert.Throws <ArgumentException>(() => Quicksort.Sort(t)); }
public void initialize() { ex = new Experiment(); qui = new Quicksort(); }