[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/primary-code-test/Java/dev/Sorts/BubbleSortRecursion.java [Back]  [Original]

package Sorts;

import java.util.Random;

/** BubbleSort algorithm implements using recursion */
public class BubbleSortRecursion implements SortAlgorithm {
  public static void main(String[] args) {
    Integer[] array = new Integer[10];

    Random random = new Random();
    /* generate 10 random numbers from -50 to 49 */
    for (int i = 0; i < array.length; ++i) {
      array[i] = random.nextInt(100) - 50;
    }

    BubbleSortRecursion bubbleSortRecursion = new BubbleSortRecursion();
    bubbleSortRecursion.sort(array);

    /* check array is sorted or not */
    for (int i = 0; i < array.length - 1; ++i) {
      assert (array[i].compareTo(array[i + 1]) 

Web Proxy Viewer  |  New URL  |  Original Page