Assuming you have a task to sort the telephone numbers of a

Assuming you have a task to sort the telephone numbers of a major carrier. What sorting algorithm will you use? Please justify your answers.

Solution

Bucket sort with some modifications will be a good sorting algorithm for phone numbers especially for a major carrier.
Assume that we are sorting a large number of telephone phone numbers, say
all residential phone numbers in the 412 area code region.
Sorting algorithm specifies the way to arrange data in a particular order.
Most common orders are numerical or lexicographical order.
We sort the phone numbers without use of comparisons by
creating an a bit array of size 107.
It takes about 1Mb. Set all bits to 0.
For each phone number turn-on the bit indexed by that phone number.
Then, go through the array and for each bit 1 record its index,
which is a phone number.

You can immediately see two drawbacks to this sorting algorithm.
Firstly, we must know how to handle duplicates.
Secondly, we must know the maximum value in the unsorted array.
Thirdly, we must have enough memory,it may be impossible to
declare an array large enough on some systems like major carrier.

The first problem can besolved by using linked lists, attached to each array index.
All duplicates for that bucket will be stored in the list.
Another possible solution is to initialize a counter.
For example let us sort 3, 2, 4, 2, 3, 5. We start with an array of 5 counters set to zero.

Assuming you have a task to sort the telephone numbers of a major carrier. What sorting algorithm will you use? Please justify your answers.SolutionBucket sort

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site