GRD Journals- Global Research and Development Journal for Engineering | Volume 5 | Issue 5 | April 2020 ISSN- 2455-5703 Defining a Modified Cycle Sort Algorithm and

Parallel Critique with other Sorting Algorithms

Nakib Aman Turzo Lecturer Department of Computer Science and Engineering Varendra University

Pritom Sarker Biplob Kumar Student Student Department of Computer Science and Engineering Department of Computer Science and Engineering Varendra University Varendra University

Jyotirmoy Ghose Amit Chakraborty Student Student Department of Computer Science and Engineering Department of Computer Science and Engineering National Institute of Technology, Rourkela Varendra University

Abstract

Professionals of computer sciences have to confront with different complexities and problems. The pivot point of the problem which requires the focus is . Sorting is the rearrangement of items or integers in an ordered way. In this research platform a modified cycle sort algorithm was devised and then comparative study of different sorting algorithms like , , Cycle sort and is being done. We also used other variety of other sorting algorithms with it. An entirely modified concept which is being sorted out. A program instigated in python has been used for gauging of CPU time taken by each algorithm. Results were obtained after cataloguing and graphically represented. For core precision program was casted a number of times and it’s concluded that modified cycle sort was the best option among all linear sorting algorithms where we have duplicate data and for large inputs efficiency has also ascended. Keywords- Sorting Algorithms, Cycle Sort, Merge Sort, Bubble Sort, Selection Sort,

I. INTRODUCTION An algorithm is an explicit, precise, unambiguous, mechanically executable sequence of elementary instructions, usually intended to accomplish a specific purpose. Sorting is the rejigging of deets in an ordered sequence. Computer technology is incessantly maturing, and new frameworks are being instigated to the market. The plot of different mechanisms with multiple cores involves programming for many analytical processors working separately. The application is aligned on dedicated assortment of concerns for effective information managing. These facets make it viable to manage even more details in various databases. Algorithms that are most useful are different sorting methods. The data constituents which needs to be sorted are normally stored in array data structure to amass it in accordance to data elements. Most software applications sort data in ascending or descending order that is why sorting algorithms have a paramount importance in these tasks. There are many fundamental and evolved sorting methods which are used for specific purpose. It is of key importance because it enhances the usefulness of data. It has risen in parallel with human mind burgeoning. Flourishment of information leads to increase in sort algorithms establishment. Their progress plummeted the complexity and allured a great deal of research. From finding a word from dictionary to finding a number or address from a directory is not so vapid now. Several sorting algorithms are present today like merge sort, bubble sort, , quick sort, selection sort and each one of them has separate mechanism to organize various elements so that performance and efficiency get rocketed. While doing comparison there are many factors which must be taken into account like time complexity i.e. the proportion of time taken by the sorting algorithm to trot. This factor is quiet vary in every sorting algorithm because of the bulk of data and may be inefficient or too slow. The time complexity can be depicted as O (n) notation. Here O represents complexity and n represents the number of elementary operations done. Second factor which is focused is stability i.e. algorithms keep the constituents with same values in the same sequence in modified array. Some sorting algorithms are stable by nature like insertion sort, merge sort, bubble sort while others are not stable and need to be modified to stable. The third factor is memory space which depicts that most sorting algorithms which use recursive techniques cover more memory. In this article, we have used our analytical approach to compare different sorting algorithms with newly devised counting (cycle) sort algorithm by modifying a previous one and tried to elaborate it in a simple way. Also presented some previous comparative studies of different people who have done it exceptionally. It’s a stark reality that critical research is the base of knowledge.

All rights reserved by www.grdjournals.com 1 Defining a Modified Cycle Sort Algorithm and Parallel Critique with other Sorting Algorithms (GRDJE/ Volume 5 / Issue 5 / 001)

II. LITERATURE REVIEW There are various groundwork or analysis available in determination of complexity of sorting algorithms. In comparative study of some parallel sort algorithms such as map sort, merge sort, parallel quick sort, alternative quick sort and the intent was to introduce merge sort algorithm and its capability to sort n-sized array of elements. Maintaining the Integrity of the Specifications. The stratagem adopted was divide and conquer method. Pragmatic and postulator analysis of merge sort algorithm was presented in addition to its pseudo codes. Merge sort was compared with bubble, insertion and selection and manifests that merge sort is faster than insertion sort with a ratio of 24 to 241 times and using n-values of 10,000 and 60,000 respectively. Results also showed that difference between merge and insertion sort is significant with 90% confidence [1, 6]. A practical performance was done by comparing odd-even transposition sort, parallel rank sort, and parallel merge sort [7]. There are many studies which addressed problems associated to dedicated and parallel machines; but a little research has been carried out on performance evaluation of parallel sorting algorithms on clustered stations. Hence, the aim of the study is to compare some parallel sorting algorithms with overall execution time as performance parameter. Algorithms taken into consideration include odd-even transposition sort, parallel rank sort, and parallel merge sort. These algorithms were evaluated in the same way as done by [6]. In theory, the odd-even transposition has a complexity of O (bn2); such that b = 1/2p2. This implicates that the time will be decreased by ‘b’. Similarly, in theory parallel rank sort has a complexity of O (cn2); c = 1/p. The theoretical complexity of parallel merge sort is O (n/p log n/p). ‘P’ is number of processes. Empirical results have shown that fastest one is parallel merge technique. This is followed by the odd-even transposition algorithm, while the slowest is the parallel rank sorting algorithm [2, 8]. In a study of Bubble, Insertion, Quick, Merge and Heap sorting algorithms on 100000, 300000, 500000, 700000, 1000000, 1500000 input values. After analyzing the data empirically algorithms were ranked in the order prescribed below with respect to speed. 1. Merge 2. Quick 3. Heap 4. Insertion 5. Bubble Merge, quickly and heap sort algorithms are faster than the remaining two because of large input size [9]. In another study bubble, insertion, selection, merge and quick sort algorithms on the input values 10, 100, 1000 and 10000. Average running time was noted on these inputs and presented graphically and concluded that the most effective and efficient algorithm was quick sort [10]. Algorithms complexity was determined by variety of criteria’s. In a study it was defined that time needed by an algorithm expressed as a function of the size of a problem is called time complexity and limiting behavior of complexity as size increases is called asymptomatic time complexity. It’s the complexity of an algorithm which determines the size of problem that can be achieved with an increase in computer speed [11]. An empirical comparison of runtime of five sorting algorithms was done to determine which one is fastest to sort lists of different lengths and to determine which algorithms to be used. Other factors were also taken into account in order to guarantee a high-quality product [12].In a research, sorting methods were divided into two categories. If data are sorted at a time in main memory it will be internal sorting but if data are sorted in auxiliary memory, it's called external memory [5, 13].In another study analysis of no-comparison based sorting algorithms was done which make assumptions about the input. All elements are required to fall within a range of constant length in order to ensure linear time complexity. On the other hand comparison based sorting algorithms make no assumption about input and are able to address any case [6, 14]. In an investigative study, different types of sorting algorithms for the allocation of CPU, as it is mastermind of computer. Scheduling of CPU is the basis of effective utilization of various resources which are attached to CPU. In this process allocation of CPU to a particular time was done so that we can take maximum usage from it. It involves the careful examination of pending processes to determine the most efficient way to service the request [15]. Processing time of four sorting algorithms was taken with index sort and it was noted that which algorithm takes less time to sort elements. If any algorithm takes less processing time which means that it sorts elements faster than others. The processing time depends on processing speed of a processor as well as internal memory used by system. It was concluded that index sort algorithm is working well for all length of input values. It took less CPU time than other sorting algorithms for small inputs. More effective sorting algorithm can be proposed with running time [3, 16]. Analysis of robustness of sorting and tournament algorithms against faulty comparisons. Sorting algorithms were affected differently by faulty comparisons depending on how comparison errors can affect the overall result. There exists a tradeoff between the number of comparisons and results accuracy but some algorithms are Pareto-dominant over others. Accuracy of top rankings is of higher importance than the lower rankings, for this purpose Swiss algorithms were considered as option. An iterated knockout system was also proposed which was less exact but more efficient than Swiss system [17]. A two- way sorting algorithm was proposed named “An End-End Bi-directional Sorting Algorithm” to address the shortcomings of current popular sorting algorithms. Its goal is to do an extensive empirical analysis of newly developed algorithm and present its functionality. The result proved that EEBS is much more efficient than other algorithms having O (n2) complexity [4, 18].

All rights reserved by www.grdjournals.com 2

Defining a Modified Cycle Sort Algorithm and Parallel Critique with other Sorting Algorithms (GRDJE/ Volume 5 / Issue 5 / 001)

The correctness of algorithm, detailed time complexity analysis and applications of algorithm was proved by using methodology of indexing in insertion sort efficiently to give much better performance [19].Several models of a computer the random access machine, the Turing machine and the random access stored program machine. These models were compared and several specialized models were derived from them. Namely straight-line arithmetic sequences, bitwise computations and decision trees and introduced a language called “Pidgin ALGOL” for describing algorithms [7, 20].

III. METHODOLOGY Applied collations are always machine contingent. For expediting investigators, who contemplate to vigor the outcomes, it’s crucial to bluntly elucidate the machine used for practical work. For gauging of CPU time taken by each algorithm, a program is instigated in python. The proposition for data file used in it embodies 1-100, 1-1000, and 1-1000 in primed, subjugated, average and two folds of number cases. On Windows 10 (64bit, Computer used for this aim was CPU 6200U @2.40 GHz, Intel(R) Core (TM) i5 this program was enacted. 8.00 GB of memory was lodged. After streaming the program on all inputs exhaustion of CPU time was taken into account using python library named time. Cataloguing and graphical designation was generated in MS Excel and then conclusion was made out of it. We fabricated 23-30 bit integer randomly after entering data. And in four ways we have contrived our input data. In the most suitable cases in levitating pattern we organized our numerical data and scheduled information in slant order on worst case. We copied input finally after randomly devising inputs, where 20% inputs are idiosyncratic and all of the other input data are duplicates. An in-situ sorting algorithm is Cycle sort. For elaboration of this sort suggestion, a log with discrete items is being taken into account. We can demonstrate the index at which it will take place in the sorted list by straight forwardly, given the items in log, counting the sundry of elements in the whole log that are lesser. There is no need to do anything if the element is hitherto at scrupulous position, if not, we have to place it to its required position. That orientation is occupied by a different element b, which we then have to displace to its right position. Positioning of items is being kept on going to their right places until an element is moved to the prototypical position of a. This finishes a cycle. Echoing this process for every element organize the log, with a single writing performance if and only if an element is not already at its right place. O (n) time has been taken for calculating the correct place for single element, thus concluding in a quadratic time algorithm, the amount of writing operations is decreased. We summate few additional logic on the code. We simply counted the amount of itemized products in the whole log of cycle sort that are lesser than opted element. But in our case we have summated an additional logic. It will store that index value if the opted elements are being duplicated into another array for that element. It’s not compulsory to count the index when we get duplicate value next time. We can simply check the index from the duplicate array and then place the value on right index. So it conserves plenty of time

A. Pseudo Code for Modified Cycle Sort Array Sorted_Array Dictionary repeated_Index For index=0 to length (arrayToSort): Current_index = 0 If arrayToSort [index] in repeated_Index: Current_index = repeated_Index[arrayToSort [index]] +1 repeated_Index [arrayToSort [index]] = +1 Else: For inner_index = index to length (arrayToSort): If arrayToSort [index]>arrayToSort [inner_index]: Current_index += 1 If arrayToSort [index] > arrayToSort [inner_index]: Got_Duplicate = True If Got_Duplicate is True: repeated_Index [arrayToSort [index]] = Current_index Sorted_Array [Current_index] = arrayToSort [index]

IV. RESULT For the effectiveness and precision we casted the program 10 times for each algorithm with same input and we took the mean value of time. And our time measurement unit is second. For accuracy stopwatch can be used for efficiency measurement. Thomas Mayrhofer stopwatch may provide result 25%-30% different for the same code executed repeatedly.

All rights reserved by www.grdjournals.com 3

Defining a Modified Cycle Sort Algorithm and Parallel Critique with other Sorting Algorithms (GRDJE/ Volume 5 / Issue 5 / 001)

A. For 100 Input Data In 100 deets storage, the graph shows that it gives stunted run time amid all others sorting algorithms. Merge sort being a stable sort has time complexity of (n log n). Here modified cycle sort also has chunk of merge sort. For ascending run time higher and with more efficiency, we summated extra scanted statements in comparison to all other algorithms.

Fig. 1: Best case time

Fig. 2: Worst case time

Fig. 3: Random case time

Fig. 4: Duplicate case time

All rights reserved by www.grdjournals.com 4

Defining a Modified Cycle Sort Algorithm and Parallel Critique with other Sorting Algorithms (GRDJE/ Volume 5 / Issue 5 / 001)

Table 1: Comparison Table for 100 inputs Selection Bubble Merge Cycle Modified Cycle Best Case Time (s) 0.002709 0.002039 0.00117 0.001895 0.001995 Worst Case Time(s) 0.002095 0.002291 0.000698 0.001197 0.001407 Random Case Time(s) 0.002128 0.002793 0.001197 0.001297 0.001505 Duplicate Case Time(s) 0.002094 0.002195 0.000585 0.001396 0.0003

B. For 1000 Input Data In 1000 deets storage, there is smitched escalation in run time for both best and worst case. Execution was peerless amid all algorithms in case of duplicate data. Runtime was 31 counts swift than the real algorithms in duplicate data case. Also street ahead execution was done in random data as compared to cycle sort algorithm.

Fig. 5: Best case time

Fig. 6: Worst case time

Fig. 7: Random case time

All rights reserved by www.grdjournals.com 5

Defining a Modified Cycle Sort Algorithm and Parallel Critique with other Sorting Algorithms (GRDJE/ Volume 5 / Issue 5 / 001)

Fig. 8: Duplicate case time

Table 2: Comparison Table for 1000 inputs Selection Bubble Merge Cycle Modified Cycle Best Case Time (s) 0.299347 0.240991 0.008727 0.119908 0.123036 Worst Case Time(s) 0.230567 0.283222 0.00883 0.191499 0.204124 Random Case Time(s) 0.255389 0.256774 0.013891 0.219701 0.166769 Duplicate Case Time(s) 0.22623 0.251893 0.015267 0.310246 0.010743

C. For 10000 Input Data Execution of modified cycle sort algorithm was street ahead amid all other sorting algorithms we have seen. In collation to original cycle sort its 146 times expeditious and more efficient. Its effectuation is one step ahead in comparison to original algorithm in random data case.

Fig. 9: Best case time

Fig. 10: Worst case time

All rights reserved by www.grdjournals.com 6

Defining a Modified Cycle Sort Algorithm and Parallel Critique with other Sorting Algorithms (GRDJE/ Volume 5 / Issue 5 / 001)

Fig. 11: Random case time

Fig. 12: Duplicate case time

Table 3: Comparison Table for 10000 inputs Selection Bubble Merge Cycle Modified Cycle Best Case Time (s) 21.32525 23.32182 0.109802 13.69929 14.92825 Worst Case Time(s) 21.51125 30.57501 0.11938 14.5634 15.99577 Random Case Time(s) 23.75918 29.32495 0.127758 16.40752 14.78767 Duplicate Case Time(s) 22.87081 27.59448 0.119185 16.00827 0.112203 When number of data as shown above has increased then the run-time has decreased in modified cycle sort for duplicate inputs. For 100 data there was a small difference in best, worst and random stages but when the number of inputs has increased then the modified cycle sort performance got well on random case also. And for 1000, 10000 inputs we have seen that its way faster than the cycle sort and all other algorithms.

V. CONCLUSION For large number of inputs, performance has increased and we can say that modified cycle sort where we have duplicate data can be used more effectively. But for smaller inputs and decreased efficiency we can use cycle sort. Its performance decreases for larger inputs that is why modified cycle sort is considered the best. It has given exceptional performance among all five sorting algorithms for duplicate data and graded the exceptional.

REFERENCES

[1] Aho A., H. J. (1974). The Design and Analysis of Computer Algorithms. [2] ali, K. (2017). A Comparative Study of Well Known Sorting Algorithms. International Journal of Advanced Research in Computer Science. [3] Bharadwaj, A. &. (2013). Comparison of Sorting Algorithms based in Input Sequences. International Journal of Computer Applications. [4] Chhajed, N. &. (2013). A Comparison Based Analysis of Different Types of Sorting Algorithms with their Performances. Indian Journal of Research Paripex. [5] Elmenreich, W. I. (2009). Robustness versus performance in sorting and tournament algorithms. Acta Polytechnica Hungarica. [6] Joshi, R. P. (2013). Analysis of Non-Comparison Based Sorting Algorithms: A Review. International Journal of Emerging Research in Management & Technology.

All rights reserved by www.grdjournals.com 7

Defining a Modified Cycle Sort Algorithm and Parallel Critique with other Sorting Algorithms (GRDJE/ Volume 5 / Issue 5 / 001)

[7] K., Q. (2018). A Practical Performance Comparison of Parallel Sorting Algorithms on Homogeneous Network of Workstations. [8] Kapur, E. K. (2012). Proposal of a two way sorting algorithm and performance comparison with existing algorithms. International Journal of Computer Science. [9] Khalid Suleiman Al-Kharabsheh, I. M. (2013). Review on Sorting Algorithms A Comparative Study. International Journal of Computer Science and Security (IJCSS. [10] Kumar, G. &. (2013). Empirical Study of Complexity Graphs for Sorting Algorithms. International Journal of Computer and Communication and Information Technology (IJCCIT). [11] M, Q. (2019). Merge Sort Algorithm”, Department of Computer Sciences, Florida Institute of. [12] Marszałek, Z. (2017). Parallelization of Modified Merge Sort Algorithm. MDPI. [13] Naeem Akhter, M. I.-u.-R. (2016). Sorting Algorithms – A Comparative Study. International Journal of Computer Science and Information Security (IJCSIS). [14] Pandey, K. K. (2014). A Comparative Study of Different Types of comparison Based Sorting Algorithms in Data Structure. ijarcsse. [15] Pasetto D, A. A. (2019). “A comparative study of parallel sort algorithms”. [16] Pena, J. O. (2008). An empirical comparison of the runtime of five sorting algorithms. International Baccalaureate Extended Essay. [17] Sareen, P. (2013). Comparison of Sorting Algorithms (On the Basis of Average Time). International Journal of Advanced Research in Computer Science & Software Engineering. [18] Thomas H. Cormen, C. E. (2009). Introduction to Algorithms. MIT Press. [19] V.Aho Alfred, E. J. (1974). The Design and Analysis of Computer Algorithms. Addison Wesley. [20] Varinder Kumar Bansal, R. S. (2009). Indexed Array Algorithm for Sorting. International Conference on Advances in Computing, Control, and Telecommunication Technologies.

All rights reserved by www.grdjournals.com 8