Esempio n. 1
0
  // @Test
  public void graphQuicksort() {

    System.out.println("size, time");

    for (int i = 0; i < 300; i++) {
      int size = Sort.randBoundInt(r, 100, 10000);

      Random pop = new Random(42);

      ArrayList<Integer> arr = new ArrayList<Integer>(size);
      for (int j = 0; j < size; j++) {
        arr.add(pop.nextInt());
      }

      Integer[] a = arr.toArray(new Integer[0]);

      long startTime = System.nanoTime();

      Sort.<Integer>quicksort(a, new Random());

      long stopTime = System.nanoTime();
      long elapsedTime = stopTime - startTime;
      System.out.println(size + ", " + elapsedTime);
    }
  }
Esempio n. 2
0
  @Test(timeout = 24)
  public void testQuicksort() {
    // Integer[] a = {10,4,6,45,68,30,61,5,21,11};
    Integer[] b = {10, 4, 6, 45, 68, 30, 61, 5, 21, 11};

    Sort.<Integer>quicksort(b, new Random());

    // System.out.println(Arrays.asList(a));
    // System.out.println(Arrays.asList(b));

    assertTrue(isAsc(b));
  }