Exemple #1
0
  // @Test
  public void graphBubbleSort() {

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

    for (int i = 0; i < 255; 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>bubblesort(a);

      long stopTime = System.nanoTime();
      long elapsedTime = stopTime - startTime;
      System.out.println(size + ", " + elapsedTime);
    }
  }
Exemple #2
0
  @Test(timeout = 110)
  public void testBubbleSort() {
    // 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>bubblesort(b);

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

    assertTrue(isAsc(b));
  }