Question: We are given a non sorted array of numbers. The sorted place of a number is the index of the number in the sorted array.

We are given a non sorted array of numbers. The sorted place of a number is the index of the number in the sorted array. Assume the array starts with A[1]. For example, see < 6, 2, 15, 5, 3, 8, 13 >. The sorted array is < 2, 3, 5, 6, 8, 13, 15 > Therefore, the sorted place of 6 is 4. The sorted place of 15 is 7. Say that in our array any number is at most 20 places from its sorted place. For example the sorted place of A[30] can be anywhere between A[10] to A[50]. For A[4] is anywhere between A[1] to A[24], the sorted place is anywhere between A[1] to A[24]. Write an algorithm that sorts under this assumption.

Explain your algorithm in words.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!