You are on page 1of 2

Marc Adrian G.

Agrade
BSIT – A305

Bubble sort:
21, 4, 25, 16
4, 21, 25, 16
4, 16, 21, 25
4, 16, 21, 25 (sorted)
Selection sort:
21, 4, 25, 16, 12, 17
4, 21, 25, 16, 12, 17
4, 12, 25, 16, 21, 17
4, 12, 16, 25, 21, 17
4, 12, 16, 17, 21, 25
4, 12, 16, 17, 21, 25 (sorted)
Insertion sort:
21, 4, 25, 16, 12
4, 21, 25, 16, 12
4, 16, 21, 25, 12
4, 12, 16, 21, 25
4, 12, 16, 21, 25 (sorted)

Shell sort is a variant of insertion sort, so the process is related, but with a gap between the
elements being compared and swapped. The exact gap size and number of steps would
depend on the specific implementation of the algorithm.

Merge sort:
21, 4, 25, 16, 12, 17, 3, 30
[21, 4], [25, 16, 12, 17, 3, 30]
[4, 21], [16, 12, 17, 3, 25, 30]
[4, 21, 16, 12], [17, 3, 25, 30]
[4, 12, 16, 21], [3, 17, 25, 30]
[3, 4, 12, 16, 17, 21, 25, 30] (sorted)

You might also like