Answers for "java bubble sort short circuit"

0

java bubble sort short circuit

public static void BubbleSortShortSC(int[] array)
    {
        for(int i = 0; i < array.length - 1; i++)
        {
            boolean sorted = true;
            for (int j = 0; j < array.length - i - 1; j++)
            {
                if(array[j] < array[j+1])
                {
                    int temp = array[j];
                    array[j] = array[j+1];
                    array[j+1] = temp;
                    sorted = false;
                }
            }
            if (sorted)
            	break;
        }
    }
Posted by: Guest on April-23-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language