A COMPARATIVE STUDY OF VARIOUS TYPES OF SORTING TECHNIQUES

: Sorting is the procedure of arranging the elements in ascending or descending order. Sorting algorithms are not only used in computer science but also in our day-to-day life to reduce complexity. For optimizing the use of other algorithms, efficient sorting is required. This paper makes a comparison between merge sort, quick sort, selection sort and insertion sort by their time complexities.


I. INTRODUCTION
Algorithm is determined as a limited collection of consecutive steps through which the solution of a particular problem is obtained. An algorithm has to produce an output for the given set of input values. The considered number of steps in any programming language should be definite and unambiguous. Each and every instruction must be such that it can be executed easily.
Many relevant algorithms can be made by using a variety of designing procedures. The various techniques taken into account are divide-and-conquer, incremental approach, greedy method, dynamic programming, backtracking and branch and bound [1].
An algorithm that rearranges the elements of a list in a certain order, for instance ascending and descending order is referred to as a sorting algorithm. Numerical order and lexicographical order are the most-used orders. There are many sorting algorithms like merge sort, insertion sort, and quick sort [2].
The sorting algorithms efficiency depends on the number of input values, some algorithms perform best when given small number of input values while other perform best when given large number. Algorithms efficiency is judged by its time complexity, time complexity is the amount of time taken by an algorithm to solve a particular problem. It is divided into three cases, best case, worst case and average case. The best case is denoted by Ω (Lower -Bound), worst case by Big-O-notation (Upper-Bound) and average case by θ (Tight-Bound).
There are two types of sorting-Internal sorting and External Sorting. If the list to be sorted is stored in the main memory, then the sorting operation is called as Internal Sorting. On the other hand, if the list is stored in the secondary memory (floppy, hard disk, etc) then the sorting is referred to as External Sorting.

A. Merge Sort
Merge Sort algorithm, which was invented by John von Neumann in 1945, is a comparison based sorting algorithm. Divide and conquer paradigm is used by merge sort algorithm to accomplish the task of sorting. The beginning of this algorithm includes comparing each pair of elements and interchanging them if the first element is greater than the second one. After that, each pair of pairs is merged into sorted quadruplets and then into two sorted sub arrays and finally a single sorted array list is obtained. It has O (n log n) worst case time complexity, which is quite efficient [3]. The merge sort algorithm can be represented as follows [4]: Step 6 else goto

B. Quick Sort
Quick Sort algorithm, also known as partition-exchange sort was developed by Tony Hoare in 1959. It is an efficient, recursive, comparison based and divide and conquer sorting algorithm in which each element is placed in its proper location at every step. It first picks up a random element, called a pivot value from the list. The partitioning is done such that the elements that are less than the pivot are moved before the pivot and the elements that are greater than the pivot are moved after it. The whole procedure is applied recursively for both the obtained sub lists separately [6]. Despite of the slow worst case running time as θ(n 2 ) ,it is the most popular sorting technique because of the average running time being θ(n log n).It is an in place sorting technique, that is it will not acquire any additional storage. The following algorithm demonstrates the quick sort technique [7].

C. Selection Sort
Selection Sort follows incremental approach, in this if one element is positioned at its suitable place then the index is incremented. In selection sort, first the least element in the array list is found, then it is interchanged with the first element of the list, after that we again find the least element in array not considering the first element (an array without first element) and interchange with the second element and it goes on until we get the sorted list. Selection Sort has worst case time complexity of O (n 2 ) [9]. The selection sort technique is represented in Fig. 3 [10]:

D. Insertion Sort
Insertion sort is the most effective sorting algorithm when we have to sort a small number of input values [11]. Insertion Sort is based on Bridge-Payer method. It is like arranging the playing cards when distributed, with an empty left hand and a pile of cards on the desk. We start removing one card from the desk and insert it into its appropriate place in the left hand [12].

III. A COMPARISON OF DIFFERENT ALGORITHMS
The following table gives the summary of the best-case, average-case and worst-case time complexity of the sorting techniques [13]. Table I The various advantages and disadvantages of the various sorting techniques are given in the table below [14].