Assignment
Assignment
Apply logic toarrange them in ascending order showcase step by step for the same ?
23 55 43 78 12 33 42 2
23 55 43 78 12 33 42 2
FIRST PASS--
Sorting will start from the initial two elements. Let compare them to check which is greater
23 55 43 78 12 33 42 2
Here, 55 is greater than 23 (55 > 23), so it is already sorted. Now, compare 55 with 43.
23 55 43 78 12 33 42 2
Here, 43 is smaller than 55. So, swapping is required. After swapping new array will look like -
23 43 55 78 12 33 42 2
Here, 78 is greater than 55. So, there is no swapping required as they are already sorted.
23 43 55 78 12 33 42 2
Here, 12 is smaller than 78 that are not sorted. So, swapping is required
23 43 55 12 78 33 42 2
23 43 55 12 33 78 42 2
23 43 55 12 33 42 78 2
Here 78 is greater than 2 . so , swapping is required.Now, we reach at the end of the array.
23 43 55 12 33 42 2 78
SECOND PASS--
23 43 55 12 33 42 2 78
23 43 55 12 33 42 2 78
23 43 55 12 33 42 2 78
Here, 12 is smaller than 55. So, swapping is required. After swapping, the array will be--
23 43 12 55 33 42 2 78
Here, 33 is smaller than 55. So, swapping is required. After swapping, the array will be--
23 43 12 33 55 42 2 78
Here, 42 is smaller than 55. So, swapping is required. After swapping, the array will be--
23 43 12 33 42 55 2 78
Here, 2 is smaller than 55. So, swapping is required. After swapping, the array will be--
23 43 12 33 42 2 55 78
23 43 12 33 42 2 55 78
THIRD PASS---
23 43 12 33 42 2 55 78
23 12 43 33 42 2 55 78
23 12 33 43 42 2 55 78
23 12 33 42 43 2 55 78
23 12 33 42 2 43 55 78
23 12 33 42 2 43 55 78
23 12 33 42 2 43 55 78
FPURTH PASS--
23 12 33 42 2 43 55 78
12 23 33 42 2 43 55 78
12 23 33 42 2 43 55 78
12 23 33 42 2 43 55 78
12 23 33 2 42 43 55 78
12 23 33 2 42 43 55 78
12 23 33 2 42 43 55 78
12 23 33 2 42 43 55 78
FIFTH PASS--
12 23 33 2 42 43 55 78
12 23 33 2 42 43 55 78
12 23 33 2 42 43 55 78
12 23 2 33 42 43 55 78
12 23 2 33 42 43 55 78
12 23 2 33 42 43 55 78
SIXTH PASS--
12 23 2 33 42 43 55 78
12 23 2 33 42 43 55 78
12 2 23 33 42 43 55 78
12 2 23 33 42 43 55 78
12 2 23 33 42 43 55 78
12 2 23 33 42 43 55 78
12 2 23 33 42 43 55 78
Hence, there is no swapping required.
SEVENTH PASS---
12 2 23 33 42 43 55 78
2 12 23 33 42 43 55 78
2 12 23 33 42 43 55 78
2 12 23 33 42 43 55 78
2 12 23 33 42 43 55 78
2 12 23 33 42 43 55 78
2 12 23 33 42 43 55 78
THANK YOU.