Exemplo n.º 1
0
 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];
 }
Exemplo n.º 2
0
        public void QuicksortOneElement()
        {
            SortList list = new SortList(1);

            Quicksort.quicksort(list);
        }
Exemplo n.º 3
0
        public void PartitionOneElement()
        {
            SortList list = new SortList(1);

            Assert.AreEqual(0, Quicksort.partition(list, 0, 0, 0));
        }
Exemplo n.º 4
0
 public Interface()
 {
     InitializeComponent();
     experiment = new Experiment();
     quickSort  = new Quicksort();
 }
Exemplo n.º 5
0
 public void QuickSort_OneElement_IsSorted()
 {
     int[] t = { 1 };
     Quicksort.Sort(t);
     Assert.True(IsSorted(t));
 }
Exemplo n.º 6
0
 public void QuickSort_GivenEmpty_RemainsEmpty()
 {
     int[] t = {};
     Quicksort.Sort(t);
     Assert.True(t.Length == 0);
 }
Exemplo n.º 7
0
 public void QuickSort_GivenNull_ThrowsException()
 {
     int[] t = null;
     Assert.Throws <ArgumentException>(() => Quicksort.Sort(t));
 }
Exemplo n.º 8
0
 public void initialize()
 {
     ex  = new Experiment();
     qui = new Quicksort();
 }