Sei sulla pagina 1di 5

BEST SORTING ALGORITHM FOR

NEARLY SORTED LISTS

In the field of computer science, a sorting algorithm is an algorithm that


arranges elements of a list in a certain order. The most used orders are
numerical order and lexicographical order. Efficient sorting is important
for optimizing the use of other algorithms which require input data to be
in sorted lists. It is also often useful for organizing data in a non-chaotic
fashion and for producing human-readable output.
There doesn’t exist any one foolproof sorting methodology for every
imaginable situation. So, this paper presents an in depth experimental
study or rather a comparison between 5 different algorithms that
represent themselves as the placeholders for their respective categories
of sorting algorithms as it is virtually impossible to compare all of them.

As a result this the authors of this research publication were able to


devise a novel sorting algorithm for nearly sorted lists. It is concoction
of Straight insertion sort and Quicker-sort with an added application of
merging. The Five major algorithms that were taken under consideration
are as follows:
1. Straight Insertion Sort
2. Shell Sort
3. Quicker sort
4. Straight Merge Sort
5. Heap Sort

THE STUDY
While defining the best sorting algorithm it can be said that:
 The one whose weighted sum of the number of comparisons,
moves, and exchanges (where an exchange is equal to two
comparisons or two moves) is minimal is the most efficient
algorithm.
While taking an assumption that a comparison is a binary
comparison, and a move is typically a transfer from a word in
memory to a register or vice versa, and an exchange is the
interchange of the contents of two words in memory.
Furthermore, coming to the idea of a nearly sorted list we can say that
a list is nearly sorted if only a few of its elements are out of order. The
problem is to define an easily computed measure that coincides with
intuition.

While conducting the experiment certain regulations were considered as


the comparison has been done for a specific case i.e. of Nearly Sorted
Lists. The regulations are:
 Here a measure of sorted-ness has been defined in terms of
the minimum number of elements that must be removed in
order for the remaining elements to be in order.
 The study compared several sorting algorithms on lists with
the special property of being nearly sorted. It suggests
comparing sorting algorithms on lists with other special
properties such as almost completely out of order.
 Here the sorting effort was measured by the weighted sum of
the number of comparisons, moves, and exchanges. Earlier
studies just used the number of comparisons.
THE ALGORITHM

2
After taking the above regulations under consideration the New
Algorithm that was produced as a result is stated below:
 First the original list is scanned and pairs of unordered elements
are removed and placed in another array.
 After a pair of unordered elements has been removed, the next
pair compared are the elements immediately preceding and
immediately following the pair just removed.
 After repeating this for all of the elements in the original list, the
array of unordered pairs of elements are sorted by Straight
Insertion if there are no more than 30 elements and by Quicker
-sort otherwise.
 Finally, the two sorted arrays are merged into one array.
THE INFERENCE

The results of the experiment have been tabulated for a particular set of
values that have been treated to the other five algorithms that were taken
into consideration. The following table (Table-I) presents a comparative
study of these algorithms to give the readers a better idea into the
performance (measure of sorted-ness) of the algorithms under
inspection.

3
Now When the experiment was performed for the same values using the
New sorting algorithm the following performance results were obtained
(As tabulated in Table-II)

THE CONCLUSION

The values in Table II show that the New Sorting Algorithm compares
favorably with the Straight Insertion Sort for small and very nearly

4
sorted lists and some values are one-half of the value for many of
those for the corresponding Quicker-sort.
The New Sorting Algorithm appears to take more advantage of the
sorted-ness of the list than either Straight Insertion or Quicker sort.
Also, note that in the worst case the New Sorting Algorithm reduces
to Quicker-sort, plus the size of the list number of moves for merging.
The New Sorting Algorithm also suggests that other new and faster
sorting algorithms for nearly sorted lists may be developed from
methodical combinations of sorting algorithms.
However the investigation conducted by the authors is not complete
and warrants further inspection and evaluation in terms of other
criteria that define the effectiveness of a sorting algorithm. But it can
be concluded that: taking the number of comparisons into perspective
the new sorting algorithm performs way better than the Other ones
considered in this study.

REFERENCES

“Best Sorting algorithm for nearly sorted lists by”:


Curtis R. Cook and Do Jin Kim

Potrebbero piacerti anche