Sorting in Java || Java + DSA course || Blog 9

I n this Blog we will be learning about Bubble sort , Selection sort and Insertion sort. We just sort arrays in ascending or descending order. The main thing we are going to from sorting is the logic behind it. Bubble Sort In this sort we push the heaviest element at the end during each loop. It checks itself with its front one to check if it is bigger than it, if it is , it swaps places with that particular number. If not then it doesn't change. Lets start solving: array = 21, 16, 13, 5, 54 1st Loop : 21> 16 == True .It swaps places with 16.Array now is {16,21,13,5,54} 21>13 == True. It swaps with 13. Array now is {16,13, 21,5,54} 21> 5 == True. It swaps with 5. Array now is {16,13,5, 21,54} 21>54 == False.Keep it as it is Now, array is {16,13,5, 21,54} in first Loop Here 54 is already sorted so you don't need to sort it in another loops Lets run 2nd loop 2nd Loop: 16> 13 == True. swaps with 13. {13,16,5, 21,54} 16> 5 == True. swaps with 5. ...