Open hassanabidpk opened 7 years ago
i execute your code bubble sort and tried little changed. then decreased loop count.
while (!isSorted) { isSorted = true; int numberSwap = 0; for (int j = 0; j < lastunSorted; j++) { if (inputList[j] > inputList[j + 1]) { swap(inputList, j, j + 1); numberOfSwaps++; numberSwap++; isSorted = false; } } lastunSorted = lastunSorted - (lastunSorted - numberSwap); }
Thanks. I will give it a try
i execute your code bubble sort and tried little changed. then decreased loop count.
while (!isSorted) { isSorted = true; int numberSwap = 0; for (int j = 0; j < lastunSorted; j++) { if (inputList[j] > inputList[j + 1]) { swap(inputList, j, j + 1); numberOfSwaps++; numberSwap++; isSorted = false; } } lastunSorted = lastunSorted - (lastunSorted - numberSwap); }