DjangoGirlsSeoul / studygroup_2016

For Algorithms and Django Study groups
MIT License
8 stars 11 forks source link

add buble sort java implementation #38

Open hassanabidpk opened 7 years ago

yklaus commented 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); }

hassanabidpk commented 7 years ago

Thanks. I will give it a try