International Journal of Computer Applications (0975 – 8887) Volume 78 – No.14, September 2013 7 Comparison of Sorting Algorithms based on Input Sequences Ashutosh Bharadwaj Dept. of Computer Science & Engineering BTKIT, Dwarahat Almora, Uttarakhand Shailendra Mishra, Ph.D Head of Dept. of Computer Science & Engineering BTKIT, Dwarahat Almora, Uttarakhand ABSTRACT Ordering is a very important for mankind .If anything is in unordered then it will not easily understand by anyone but if it is in order then it will easily understand and used by anyone. So ordering is a very important issue in computer science also. In computer science many programming applications use ordering to solving a problem either it is in ascending or descending order. In this paper we discuss four sorting algorithms which are already existed named as Insertion Sort, Bubble Sort, Selection Sort, Merge Sort and we design a new sorting algorithm named as index sort also. In this paper we check the performance and comparison of all five sorting algorithm on the basis of increasing the no of elements in bulk. We check how much processing time is taken by all four sorting algorithms with Index Sort and compared them and finding which sorting algorithm takes less time to sort the elements like 10, 100, 1000, 10000 . If any algorithm takes less processing time it means that it sorts the element faster than others. The processing time of a sorting algorithm is based on the processing speed of a Processor as well as internal memory (RAM) used by the system. Keywords Insertion Sort; Bubble Sort; Selection sort; Merge Sort; Index Sort. 1. INTRODUCTION Sorting is a fundamental operation in computer science. Sorting generally refers to the operation of ordering data in a given sequence such as increasing sequence or decreasing sequence. There are many fundamental and advance sorting algorithms. All sorting algorithm are problem oriented means they work well on some special problem and do not work well for any kind of a problems. Sorting algorithms are applied on specific kind of problems. Sorting algorithms are used for small number of elements, some sorting algorithms are used for large numbers, some sorting algorithms are used for floating number of data, and some are used for repeated values in a list. We sort data in numerical order or alphabetical order, arranging the list either in increasing order or decreasing order and alphabetical value like addressee key. In this paper we discuss four sorting algorithms which are already exist named as Insertion Sort, Bubble Sort, Selection Sort, Merge Sort and we design a new sorting algorithm named as index sort. In this paper we check the performance and comparison of all five sorting algorithm on the basis of increasing the no of elements in bulk. We check how much processing time is taken by all four sorting algorithms with Index Sort and compared them and finding which sorting algorithm takes less time to sort the elements like 10, 100, 1000, 10000 . If any algorithm takes less processing time it means that it sorts the element faster than others. 2. Sorting Algorithms 2.1 Insertion Sort This sorting technique is used for small number of elements. The insertion sort works like playing cards in which each card is placed at its proper place while playing in hands of a person. Cards are placed in an order which is also called a sorting order .Sorting a hand of playing card is one of the real examples of insertion sort. This algorithm first sorts the first two elements of the array. It then inserts the third element in its proper place in relation to the first 2 sorted elements. This process continues until all of the remaining elements are inserted in their proper position. Insertion sort can take different running time to sort two input sequences of the same size of array depending upon how nearly they already sorted. It sorts the element of small array very fast but in sorting the elements of big array takes very long time. Algorithm 1. For I=2 to N 2. A [I] =item, J=I-1 3. WHILE j>0 and item<A[J] 4. A[J+1]=A[J] 5. J=J-1 6. A [J+1]=item Following are the procedure to sort a given set of element {8, 7, 1, 2}. 2.2 BUBBLE SORT The sorting algorithm is affectionately named the "bubble" sort. This sorting algorithm is perhaps one of the simplest sorting algorithms in terms of complexity. It makes use of a sorting method known as the exchange method. This algorithm compares pairs of adjacent elements and makes exchanges if necessary. The name comes from the fact that each element "bubbles" up to its own proper position. Here is how bubble sort would sort the integer array 8 7 1 2,It is a simplest sorting algorithm used in computer science algorithm. If we have 100 elements then the total number of Data 8 7 1 2 Pass 1 7 8 1 2 Pass 2 1 7 8 2 Pass 3 1 2 7 8