payal-kothari
6/22/2017 - 6:45 AM

Bubble sort.java

https://www.youtube.com/watch?v=8Kp-8OGwphY
(https://www.youtube.com/watch?v=8Kp-8OGwphY)

public static void bubbleSort(int[] numArray) { 

    int n = numArray.length; 
    int temp = 0; 

    for (int i = 0; i < n; i++) { 
        for (int j = 1; j < (n - i); j++) { 

            if (numArray[j - 1] > numArray[j]) { 
                temp = numArray[j - 1]; 
                numArray[j - 1] = numArray[j]; 
                numArray[j] = temp; 
            } 
        } 
    } 
}