Computer Science, asked by IzharK, 6 months ago

4. Write a sorting algorithm for the input [45, 41, 67, 69, 32, 54, 12, 78, 65).​

Answers

Answered by logitharun
0

Answer:

Original, unsorted list:

170, 45, 75, 90, 802, 24, 2, 66

Sorting by least significant digit (1s place) gives:

[*Notice that we keep 802 before 2, because 802 occurred

before 2 in the original list, and similarly for pairs

170 & 90 and 45 & 75.]

Sorting by next digit (10s place) gives:

[*Notice that 802 again comes before 2 as 802 comes before

2 in the previous list.]

802, 2, 24, 45, 66, 170, 75, 90

Sorting by the most significant digit (100s place) gives:

2, 24, 45, 66, 75, 90, 170, 802

Similar questions