^{1}

^{2}

^{1}

^{2}

Sorting is one of the operations on data structures used in a special situation. Sorting is defined as an arrangement of data or records in a particular logical order. A number of algorithms are developed for sorting the data. The reason behind developing these algorithms is to optimize the efficiency and complexity. The work on creating new sorting approaches is still going on. With the rise in the generation of big data, the concept of big number comes into existence. To sort thousands of records either sorted or unsorted, traditional sorting approaches can be used. In those cases, we can ignore the complexities as very minute difference exists in their execution time. But in case the data are very large, where execution time or processed time of billion or trillion of records is very large, we cannot ignore the complexity at this situation; therefore, an optimized sorting approach is required. Thus, SA sorting is one of the approaches developed to check sorted big numbers as it works better on sorted numbers than quick sort and many others. It can also be used to sort unsorted records as well.

Sorting big numbers in an optimized way is a challenging task to perform. A number of such sorting algorithms exist which are optimized, but their execution time is still to be optimized. Sometimes, these algorithms take the same amount of time to sort a sorted record as they take to sort an unsorted record. The sorting algorithm should be stable, effective, less complex, and efficient. SA sorting follows most of these parameters. SA sorting is introduced as a new approach to operate on both sorted and unsorted lists or records and shows better execution time on the sorted list.

The following section discusses the existing sorting approaches.

It is a stable sorting algorithm in which each element in the list is compared with its next adjacent element, and the process is repeated until the elements are sorted. If we have

The algorithm for bubble sort is given in Algorithm

In this algorithm, if no swap occurs, it will break the loop and directly go to end, and thus, only one loop executes that determines best-case analysis which becomes

It is the stable sorting algorithm in which starting from the first number from the record, this first number is compared to every adjacent number to find its sorted position. When the position is found, the number is inserted there. The algorithm for insertion sort is given in Algorithm

Insertion sort holds good for smaller datasets since it is also code inefficient for large data/lists or big numbers. Insertion sort is 2 times faster than bubble sort. For the best case, it is

By nature, selection sort is unstable, but it can be improved to become stable. In this sorting technique, we are supposed to find the smallest number from the record, put this number at the starting position, change the position to next, and then again find the smallest number from the remaining list. This process goes on and on, until the whole list becomes sorted. This algorithm is efficient for smaller records, but for larger records, this technique is again code inefficient. The algorithm is given in Algorithm

Its execution time is better for smaller data/records (up to hundreds of records). The best-, average-, or worst-case complexity is the same as

It is a stable sorting algorithm and is very efficient to handle big numbers. It is based on the following three steps [

Divide the given list or record into number of sublists in such a way that every list or sublist is half divided

Conquer the sublist by the recursion method

Combine the sorted sublist simply by merging

The sorting is actually done in the second step. Merge sort is the only sorting technique which is purely based on the divide-and-conquer technique of solving the algorithm. It requires double the memory as required by other sorting techniques. The algorithm for merge sort is given in Algorithms

From the algorithm, it is analyzed that merge sort has the following recurrence relation:

Using the master method,

Now,

For all three cases, it would be

It is unstable but efficient and is one of the fast working sorting algorithms. It is based on the divide-and-conquer strategy. While talking about quick sort at an instant, in our mind, there comes the concept of pivot element. The pivot element is one of the randomly chosen members from the list which is under the operation of sorting. It works well for both smaller and larger lists or records, but in case if the list is sorted, some results are sometimes obtained that we cannot even imagine. It is built on the recursion phenomenon. The algorithm is given in Algorithms

The partition function works as follows:

Complexity analysis:

Let

Comparisons =

O (

If

It is an unstable sorting algorithm built on the binary search tree (BST). The element in tree sort is sorted using in-order traversing operation. Tree sort requires extra memory space, and complexity changes from balanced BST to unbalanced BST. The complexity of the tree sort is

It is a stable sorting approach. When we think that the list or record is sorted but we are not sure, we need an algorithm which works best on the sorted list; for this purpose, we use gnome sort. It performs well not only on the sorted list but also on the unsorted list. The algorithm is given in Algorithm

From the algorithms, it is clearly seen that if the list is sorted, no interchange of elements is done; hence, it executes linearly. Thus, for the best case, it is

It is a stable and easily understandable sorting algorithm. As the name depicts, counting sort works by finding the largest element in the given list/record, and then starting from the least element/number, its frequency is counted and at last the sorted list is produced maintaining the order of its occurrence while sorting. It is useful in those cases where the difference between the numbers is very small and the dataset is also very small. The step-by-step procedure of counting sort is discussed in Algorithm

Suleiman with his team of three other members proposed the GCS algorithm. The methodology they have used is to divide the given list/record into groups. Each of these groups contains three elements, and comparison is done in such a way that every element of one group is compared to that in other groups. The main drawback of this algorithm is that the input size must be less than or equal to 25000 records to get the better results. The complexity becomes

Heap sort is a stable but efficient sorting algorithm which is based on the complete binary tree and follows the heap order. Heap sort contains min heap, in which the root node is having the minimum value, and max heap, in which the root node is having the maximum value. The procedure of heap sort is explained through Algorithms

For heap sort, in all the three cases (i.e., best, average, and worst cases), the complexity is the same as

It is a stable and efficient sorting algorithm when the size of list/record is small. Internally, it acts like counting sort. One of the drawbacks of radix sort is it operates on one number many times as it has the number of significant bits on a digit. Suppose if there is a number 169, the radix sort operates on it three times, sorting from the least significant digit 9 to the most significant digit 1 in the list. Radix sort compares the LSB of all the numbers in a similar way to proceed with further results in a sorting list. The procedure of radix sort is explained in Algorithm

If the size is the longest length

It is a stable and efficient sorting algorithm as compared to bubble sort as it is the extended version of bubble sort. Cocktail sort works on both sides of the list. During sorting, it puts the largest element to the tail side and smallest element to the head side. The head side and tail side are shown in Figure

Working of cocktail sort.

Bubble sort puts the biggest element to the tail side after every pass, while cocktail sort puts the smallest element to the head side and the biggest element to the tail side after every pass. The complexity of cocktail sort for worst and average cases is

It is the stable and another improved version of bubble sort as it changes the gap size from 1 to 1.3 for every iteration. Gap size tells the algorithm to swap. As the gap size increases, the number of swaps decreases; thus, on the average-case scenario, comb sort performs better. But for the worst case, it remains the same as

It is the extended version of selection sort which is made stable by decreasing the regular size of the list. This is done in such a way that first the biggest element is found, a swap is made, the size of the list is decreased by 1, and then the sort is again performed in a similar way to get the list sorted. Although the complexity would be the same as that of selection sort but in the best-case scenario, the number of swaps would be zero for enhanced selection sort. The complexity for all the three cases would be

It is the unstable and efficient sorting algorithm which is the extended version of insertion sort. Shell sort works well if the given list is partially sorted. This means we are discussing about the average-case scenario. Shell sort uses Knuth’s formula to calculate the interval or spacing. This formula is given as follows:

For best and worst cases, the complexity is

It is a stable sort and consists of bucket. The elements are inserted in the bucket, and then, the sorting is employed on the bucket. Bucket sort does not have comparisons and uses the index to sort. These indexes are not just obtained from any mathematical function but are obtained in such a way that they could satisfy the order of arrangement of numbers inserted in the bucket. The procedure is explained in Algorithm

The complexity for bucket sort would be

It is a combination of insertion and merge sort. It is a stable and efficient sorting technique in which the list or record is split into blocks called “run.” If the size of list or record is less than run, then it can be sorted using insertion sort. The maximum size of the run would be 64 depending upon the list or record. But if the size of the unsorted list is very large, then both insertion and merge sorting techniques are used. The complexity for best, average, and worst cases is

It is another extension of bubble sort, in which the BS algorithm is partitioned into two parts: even part and odd part. Even part consists of even numbers, and odd part consists of odd numbers. Both the parts are executed one by one, and at last, the combined result is obtained and the records are sorted. It is a stable algorithm with the same complexity as the bubble sort:

It is introduced through the concept of merge sort. In bitonic sort, we move the list to level

Ali [

Hammad [

Elkahlout and Maghari [

All these algorithms are graphically implemented in this paper. The main focus is on time complexity.

Jehad and Rami [

Pankaj [

Khalid et al. [

Starting from the left extreme end of the list/record, the first element is obtained as the target. The target is compared with all the other elements until the smaller element is found. The target is swapped with the smaller element and continuously compared till the extreme right end of the list. Again, going back to the target position, a new target element is taken at that position. Similarly, it is processed in the same way. The position is not changed until the targeted element is found as is already operated. When the targeted element is found to be already operated, the position is changed to next by 1. In this way, SA sorting works. The step-by-step process of SA sorting is given in Algorithm

The number of comparisons,

Let

Now creating the recurrence relation,

Using induction to prove,

At

At

At

Solving using the master method,

However,

The proposed sorting technique is implemented in C++ and tested with different numbers of elements. The performance of the SA sorting is measured in terms of execution time and memory required for sorting. The comparison of execution time and memory used by existing sorting techniques with SA sorting is shown in Tables

Comparison of execution time in microseconds.

S. no. | No. of entries | Nature of entry | Quick | Merge | Heap | Insertion | Selection | Shell | SA |
---|---|---|---|---|---|---|---|---|---|

1 | 100 | Unsorted | 67 | 75 | 44 | 65 | 76 | 33 | 109 |

2 | 500 | Unsorted | 150 | 165 | 185 | 207 | 495 | 114 | 1078 |

3 | 1k | Unsorted | 232 | 271 | 231 | 553 | 1722 | 373 | 4223 |

4 | 5k | Unsorted | 1207 | 1389 | 2141 | 19335 | 39865 | 1452 | 124973 |

5 | 10k | Unsorted | 2359 | 2826 | 4588 | 67283 | 158382 | 3100 | 506885 |

6 | 20k | Unsorted | 4932 | 5934 | 9747 | 268644 | 627031 | 6710 | 2054339 |

7 | 1k | Sorted | 3492 | 265 | 377 | 144 | 1736 | 156 | 3146 |

Comparison of memory used in MB.

S. no. | No. of entries | Nature of entry | Quick | Merge | Heap | Insertion | Selection | Shell | SA |
---|---|---|---|---|---|---|---|---|---|

1 | 1k | Unsorted | 1.503 | 1.503 | 3.110 | 1.502 | 1.514 | 3.109 | 1.350 |

2 | 5k | Unsorted | 1.561 | 1.570 | 3.242 | 1.620 | 1.520 | 3.242 | 1.611 |

3 | 10k | Unsorted | 1.630 | 1.640 | 3.300 | 1.600 | 1.678 | 3.343 | 1.615 |

4 | 20k | Unsorted | 1.800 | 1.795 | 3.385 | 1.622 | 1.771 | 3.424 | 1.786 |

5 | 1k | Sorted | 1.470 | 1.491 | 3.230 | 1.420 | 1.510 | 3.105 | 1.413 |

While implementing all these sorting techniques and comparing them with

If we increase the space, the time reduces as shell sort and heap sort do

The sorting techniques which work well on unsorted records are not very good on sorted records as quick sort and merge sort do

In the worst-case scenario, most of the sorting techniques rely on

No sorting technique is universally used, and its usage depends upon their nature and users requirement

SA sorting needs to be improved and optimized in the future

Our article is purely based on algorithm design. We evolve our results from unsorted and sorted data files which include different records, in order to compare the algorithm with already established algorithms. Thus, no such proper data have been used.

The authors declare that they have no conflicts of interest.