Say that the different values in an unsorted array are only

Say that the different values in an unsorted array are only 10 values (each repeating many times). Give an algorithm to sort the array.

Example: in < 1, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 2, 3 > there are many numbers but only 3 different values.

Solution

Explaing here the overview of steps of the algorithm:

1.) Get the values which are duplicated in the array.

2.) Get the count of values in for each duplicated value.

3.)Get the array with the unique values.

4.)Sort the array.

5.)Insert the duplicate values in the array with the number of count done earlier.

Say that the different values in an unsorted array are only 10 values (each repeating many times). Give an algorithm to sort the array. Example: in < 1, 2, 1

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site