Radix Sorts Examples Interface Digital { ! Strings Public Int Charat(Int K); ! 64-Bit Integers Public Int Length(Int); Static Int R(); }

Total Page:16

File Type:pdf, Size:1020Kb

Radix Sorts Examples Interface Digital { ! Strings Public Int Charat(Int K); ! 64-Bit Integers Public Int Length(Int); Static Int R(); } Digital keys Many commonly-use key types are inherently digital (sequences of fixed-length characters) interface Radix Sorts Examples interface Digital { ! Strings public int charAt(int k); ! 64-bit integers public int length(int); static int R(); } • key-indexed counting This lecture: • LSD radix sort ! refer to fixed-length vs. variable-length strings • MSD radix sort ! R different characters • 3-way radix quicksort ! key type implements charAt() and length() methods • application: LRS ! code works for String and key types that implement Digital. Widely used in practice References: Algorithms in Java, Chapter 10 ! low-level bit-based sorts Intro to Algs and Data Structs, Section 6.1 ! string sorts Copyright © 2007 by Robert Sedgewick and Kevin Wayne. 3 Review: summary of the performance of sorting algorithms Frequency of execution of instructions in the inner loop: algorithm guarantee average extra assumptions space on keys 2 2 insertion sort N /2 N /4 no Comparable key-indexed counting 2 2 selection sort N /2 N /2 no Comparable LSD radix sort mergesort N lg N N lg N N Comparable MSD radix sort quicksort 1.39 N lg N 1.39 N lg N c lg N Comparable 3-way radix quicksort application: LRS lower bound: N lg N -1.44 N compares are required by any algorithm Q: Can we do better (despite the lower bound)? 2 4 Key-indexed counting: assumptions about keys Key-indexed counting Assume that keys are integers between 0 and R-1 Task: sort an array a[] of N integers between 0 and R-1 Plan: produce sorted result in array temp[] Examples: 1. Count frequencies of each letter using key as index ! char (R = 256) 2. Compute frequency cumulates which specify destinations ! short with fixed R, enforced by client ! int with fixed R, enforced by client a[] temp[] 0 d 0 int N = a.length; Reminder: equal keys are allowed in sorts int[] count = new int[R]; 1 a 1 2 c count[] 2 count for (int i = 0; i < N; i++) 3 f a 0 3 Applications: frequencies count[a[i]+1]++; 4 f b 2 4 ! sort phone numbers by area code 5 b c 5 5 ! sort classlist by precept compute for (int i = 1; i < 256; i++) 6 d 6 d cumulates d 6 ! Requirement: sort must be stable count[i] += count[i-1]; 7 b e 8 7 d ! Ex: Full sort on primary key, then stable radix sort on secondary key 8 f f 9 8 9 b 9 10 e 10 11 a 11 Implication: Can use key as an array index 6 keys < d, 8 keys < e so d’s go in a[6] and a[7] 5 7 Key-indexed counting Key-indexed counting Task: sort an array a[] of N integers between 0 and R-1 Task: sort an array a[] of N integers between 0 and R-1 Plan: produce sorted result in array temp[] Plan: produce sorted result in array temp[] 1. Count frequencies of each letter using key as index 1. Count frequencies of each letter using key as index 2. Compute frequency cumulates which specify destinations 3. Access cumulates using key as index to move records. a[] offset by 1 temp[] a[] temp[] [stay tuned] 0 d 0 0 d 0 a int N = a.length; int N = a.length; int[] count = new int[R]; 1 a 1 int[] count = new int[R]; 1 a 1 a 2 c count[] 2 2 c count[] 2 b count for (int i = 0; i < N; i++) 3 f a 0 3 count for (int i = 0; i < N; i++) 3 f a 2 3 b frequencies frequencies count[a[i]+1]++; 4 f b 2 4 count[a[i]+1]++; 4 f b 5 4 b 5 b c 3 5 5 b c 6 5 c 6 d 6 compute for (int i = 1; i < 256; i++) 6 d 6 d d 1 cumulates d 8 7 b e 2 7 count[i] += count[i-1]; 7 b e 9 7 d 8 f f 1 8 8 f f 12 8 e 9 9 move for (int i = 0; i < N; i++) 9 9 b records b f temp[count[a[i]]++] = a[i]; 10 e 10 10 e 10 f 11 a 11 11 a 11 f 2 d’s 6 8 Key-indexed counting Task: sort an array a[] of N integers between 0 and R-1 Plan: produce sorted result in array temp[] 1. Count frequencies of each letter using key as index 2. Compute frequency cumulates 3. Access cumulates using key as index to find record positions. 4. Copy back into original array a[] temp[] key-indexed counting 0 a 0 a int N = a.length; 1 a 1 a LSD radix sort int[] count = new int[R]; 2 b count[] 2 b MSD radix sort count for (int i = 0; i < N; i++) 3 b a 2 3 b frequencies count[a[i]+1]++; 4 b b 5 4 b 3-way radix quicksort 5 c c 6 5 c application: LRS compute for (int k = 1; k < 256; k++) 6 d 6 d cumulates d 8 count[k] += count[k-1]; 7 d e 9 7 d 8 e f 12 8 e move for (int i = 0; i < N; i++) 9 9 records f f temp[count[a[i]++]] = a[i] 10 f 10 f copy back for (int i = 0; i < N; i++) 11 f 11 f a[i] = temp[i]; 9 11 Review: summary of the performance of sorting algorithms Least-significant-digit-first radix sort Frequency of execution of instructions in the inner loop: LSD radix sort. ! Consider characters d from right to left ! Stably sort using dth character as the key via key-indexed counting. extra assumptions algorithm guarantee average space on keys sort key sort key sort key insertion sort N2 /2 N2 /4 no Comparable 0 d a b 0 d a b 0 d a b 0 a c e selection sort N2 /2 N2 /2 no Comparable 1 a d d 1 c a b 1 c a b 1 a d d mergesort N lg N N lg N N Comparable 2 c a b 2 e b b 2 f a d 2 b a d 3 f a d 3 a d d 3 b a d 3 b e d quicksort 1.39 N lg N 1.39 N lg N c lg N Comparable 4 f e e 4 f a d 4 d a d 4 b e e 5 b a d 5 b a d 5 e b b 5 c a b key-indexed counting N N N + R integers 6 d a d 6 d a d 6 a c e 6 d a b 7 b e e 7 f e d 7 a d d 7 d a d 8 f e d 8 b e d 8 f e d 8 e b b inplace version is possible and practical 9 b e d 9 f e e 9 b e d 9 f a d 10 e b b 10 b e e 10 f e e 10 f e d 11 a c e 11 a c e 11 b e e 11 f e e Q: Can we do better (despite the lower bound)? A: Yes, if we do not depend on comparisons sort must be stable 10 arrows do not cross 12 LSD radix sort: Why does it work? Review: summary of the performance of sorting algorithms Frequency of execution of instructions in the inner loop: Pf 1. [thinking about the past] ! If two strings differ on first character, key- sort key indexed sort puts them in proper relative order. extra assumptions ! 0 d a b 0 a c e algorithm guarantee average If two strings agree on first character, space on keys stability keeps them in proper relative order. 1 c a b 1 a d d 2 f a d 2 b a d insertion sort N2 /2 N2 /4 no Comparable 3 b a d 3 b e d 2 2 4 d a d 4 b e e selection sort N /2 N /2 no Comparable 5 e b b 5 c a b mergesort N lg N N lg N N Comparable 6 a c e 6 d a b 7 a d d 7 d a d quicksort 1.39 N lg N 1.39 N lg N c lg N Comparable 8 8 Pf 2. [thinking about the future] f e d e b b 9 b e d 9 f a d ! LSD radix sort WN WN N + R Digital If the characters not yet examined differ, 10 f e e 10 f e d it doesn't matter what we do now. 11 b e e 11 f e e ! If the characters not yet examined agree, stability ensures later pass won't affect order. in order by previous passes 13 15 LSD radix sort implementation Sorting Challenge Use k-indexed counting on characters, moving right to left Problem: sort a huge commercial database on a fixed-length key field Ex: account number, date, SS number B14-99-8765 756-12-AD46 public static void lsd(String[] a) CX6-92-0112 Which sorting method to use? 332-WX-9877 { 375-99-QWAX 1. insertion sort int N = a.length; CV2-59-0221 387-SS-0321 int W = a[0].length; 2.
Recommended publications
  • Radix Sort Comparison Sort Runtime of O(N*Log(N)) Is Optimal
    Radix Sort Comparison sort runtime of O(n*log(n)) is optimal • The problem of sorting cannot be solved using comparisons with less than n*log(n) time complexity • See Proposition I in Chapter 2.2 of the text How can we sort without comparison? • Consider the following approach: • Look at the least-significant digit • Group numbers with the same digit • Maintain relative order • Place groups back in array together • I.e., all the 0’s, all the 1’s, all the 2’s, etc. • Repeat for increasingly significant digits The characteristics of Radix sort • Least significant digit (LSD) Radix sort • a fast stable sorting algorithm • begins at the least significant digit (e.g. the rightmost digit) • proceeds to the most significant digit (e.g. the leftmost digit) • lexicographic orderings Generally Speaking • 1. Take the least significant digit (or group of bits) of each key • 2. Group the keys based on that digit, but otherwise keep the original order of keys. • This is what makes the LSD radix sort a stable sort. • 3. Repeat the grouping process with each more significant digit Generally Speaking public static void sort(String [] a, int W) { int N = a.length; int R = 256; String [] aux = new String[N]; for (int d = W - 1; d >= 0; --d) { aux = sorted array a by the dth character a = aux } } A Radix sort example A Radix sort example A Radix sort example • Problem: How to ? • Group the keys based on that digit, • but otherwise keep the original order of keys. Key-indexed counting • 1. Take the least significant digit (or group of bits) of each key • 2.
    [Show full text]
  • Lecture 8.Key
    CSC 391/691: GPU Programming Fall 2015 Parallel Sorting Algorithms Copyright © 2015 Samuel S. Cho Sorting Algorithms Review 2 • Bubble Sort: O(n ) 2 • Insertion Sort: O(n ) • Quick Sort: O(n log n) • Heap Sort: O(n log n) • Merge Sort: O(n log n) • The best we can expect from a sequential sorting algorithm using p processors (if distributed evenly among the n elements to be sorted) is O(n log n) / p ~ O(log n). Compare and Exchange Sorting Algorithms • Form the basis of several, if not most, classical sequential sorting algorithms. • Two numbers, say A and B, are compared between P0 and P1. P0 P1 A B MIN MAX Bubble Sort • Generic example of a “bad” sorting 0 1 2 3 4 5 algorithm. start: 1 3 8 0 6 5 0 1 2 3 4 5 Algorithm: • after pass 1: 1 3 0 6 5 8 • Compare neighboring elements. • Swap if neighbor is out of order. 0 1 2 3 4 5 • Two nested loops. after pass 2: 1 0 3 5 6 8 • Stop when a whole pass 0 1 2 3 4 5 completes without any swaps. after pass 3: 0 1 3 5 6 8 0 1 2 3 4 5 • Performance: 2 after pass 4: 0 1 3 5 6 8 Worst: O(n ) • 2 • Average: O(n ) fin. • Best: O(n) "The bubble sort seems to have nothing to recommend it, except a catchy name and the fact that it leads to some interesting theoretical problems." - Donald Knuth, The Art of Computer Programming Odd-Even Transposition Sort (also Brick Sort) • Simple sorting algorithm that was introduced in 1972 by Nico Habermann who originally developed it for parallel architectures (“Parallel Neighbor-Sort”).
    [Show full text]
  • Tutorial 2: Heapsort, Quicksort, Counting Sort, Radix Sort
    Tutorial 2: Heapsort, Quicksort, Counting Sort, Radix Sort Mayank Saksena September 20, 2006 1 Heapsort We review Heapsort, and prove some loop invariants for it. For further information, see Chapter 6 of Introduction to Algorithms. HEAPSORT(A) 1 BUILD-MAX-HEAP(A) Ð eÒg Øh A 2 for i = ( ) downto 2 A i 3 swap A[1] and [ ] ×iÞ e A heaÔ ×iÞ e A 4 heaÔ- ( )= - ( ) 1 5 MAX-HEAPIFY(A; 1) BUILD-MAX-HEAP(A) ×iÞ e A Ð eÒg Øh A 1 heaÔ- ( )= ( ) Ð eÒg Øh A = 2 for i = ( ) 2 downto 1 3 MAX-HEAPIFY(A; i) MAX-HEAPIFY(A; i) i 1 Ð =LEFT( ) i 2 Ö =RIGHT( ) heaÔ ×iÞ e A A Ð > A i Ð aÖ g e×Ø Ð 3 if Ð - ( ) and ( ) ( ) then = i 4 else Ð aÖ g e×Ø = heaÔ ×iÞ e A A Ö > A Ð aÖ g e×Ø Ð aÖ g e×Ø Ö 5 if Ö - ( ) and ( ) ( ) then = i 6 if Ð aÖ g e×Ø = i A Ð aÖ g e×Ø 7 swap A[ ] and [ ] 8 MAX-HEAPIFY(A; Ð aÖ g e×Ø) 1 Loop invariants First, assume that MAX-HEAPIFY(A; i) is correct, i.e., that it makes the subtree with A root i a max-heap. Under this assumption, we prove that BUILD-MAX-HEAP( ) is correct, i.e., that it makes A a max-heap. A We show: at the start of iteration i of the for-loop of BUILD-MAX-HEAP( ) (line ; i ;:::;Ò 2), each of the nodes i +1 +2 is the root of a max-heap.
    [Show full text]
  • Sorting Algorithm 1 Sorting Algorithm
    Sorting algorithm 1 Sorting algorithm In computer science, a sorting algorithm is an algorithm that puts 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 (such as search and merge algorithms) that require sorted lists to work correctly; it is also often useful for canonicalizing data and for producing human-readable output. More formally, the output must satisfy two conditions: 1. The output is in nondecreasing order (each element is no smaller than the previous element according to the desired total order); 2. The output is a permutation, or reordering, of the input. Since the dawn of computing, the sorting problem has attracted a great deal of research, perhaps due to the complexity of solving it efficiently despite its simple, familiar statement. For example, bubble sort was analyzed as early as 1956.[1] Although many consider it a solved problem, useful new sorting algorithms are still being invented (for example, library sort was first published in 2004). Sorting algorithms are prevalent in introductory computer science classes, where the abundance of algorithms for the problem provides a gentle introduction to a variety of core algorithm concepts, such as big O notation, divide and conquer algorithms, data structures, randomized algorithms, best, worst and average case analysis, time-space tradeoffs, and lower bounds. Classification Sorting algorithms used in computer science are often classified by: • Computational complexity (worst, average and best behaviour) of element comparisons in terms of the size of the list . For typical sorting algorithms good behavior is and bad behavior is .
    [Show full text]
  • Sorting Algorithm 1 Sorting Algorithm
    Sorting algorithm 1 Sorting algorithm A sorting algorithm is an algorithm that puts 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 (such as search and merge algorithms) which require input data to be in sorted lists; it is also often useful for canonicalizing data and for producing human-readable output. More formally, the output must satisfy two conditions: 1. The output is in nondecreasing order (each element is no smaller than the previous element according to the desired total order); 2. The output is a permutation (reordering) of the input. Since the dawn of computing, the sorting problem has attracted a great deal of research, perhaps due to the complexity of solving it efficiently despite its simple, familiar statement. For example, bubble sort was analyzed as early as 1956.[1] Although many consider it a solved problem, useful new sorting algorithms are still being invented (for example, library sort was first published in 2006). Sorting algorithms are prevalent in introductory computer science classes, where the abundance of algorithms for the problem provides a gentle introduction to a variety of core algorithm concepts, such as big O notation, divide and conquer algorithms, data structures, randomized algorithms, best, worst and average case analysis, time-space tradeoffs, and upper and lower bounds. Classification Sorting algorithms are often classified by: • Computational complexity (worst, average and best behavior) of element comparisons in terms of the size of the list (n). For typical serial sorting algorithms good behavior is O(n log n), with parallel sort in O(log2 n), and bad behavior is O(n2).
    [Show full text]
  • Parallel Sorting on Multi-Core Architecture
    Parallel Sorting on Multi-core Architecture A thesis submitted in partial fulfillment of the requirements for the degree of Master of Science By Wei Wang B.S., Zhengzhou University, 2007 2011 Wright State University WRIGHT STATE UNIVERSITY SCHOOL OF GRADUATE STUDIES August 19, 2011 I HEREBY RECOMMEND THAT THE THESIS PREPARED UNDER MY SUPER- VISION BY Wei Wang ENTITLED Parallel Sorting on Multi-core Architecture BE ACCEPTED IN PARTIAL FULFILLMENT OF THE REQUIREMENTS FOR THE DEGREE OF Master of Science. Meilin Liu, Ph. D. Thesis Director Mateen Rizki, Ph.D. Department Chair Committee on Final Examination Meilin Liu, Ph. D. Jack Jean, Ph. D. T.K. Prasad, Ph. D. Andrew Hsu, Ph. D. Dean, School of Graduate Studies Copyright c 2011 Wei Wang All Rights Reserved ABSTRACT Wang, Wei. M.S. Department of Computer Science and Engineering, Wright State University, 2011. Parallel Sorting on Multi-Core Architecture. With the limitations given by the power consumption (power wall), memory wall and the instruction level parallelism, the computing industry has turned its direc- tion to multi-core architectures. Nowadays, the multi-core and many-core architectures are becoming the trend of the processor design. But how to exploit these architectures is the primary challenge for the research community. To take advantage of the multi- core architectures, the software design has undergone fundamental changes. Sorting is a fundamental, important problem in computer science. It is utilized in many applications such as databases and search engines. In this thesis, we will in- vestigate and auto-tune two parallel sorting algorithms, i.e., radix sort and sample sort on two parallel architectures, the many-core nVIDIA CUDA enabled graphics proces- sors, and the multi-core Cell Broadband Engine.
    [Show full text]
  • Comparison of Parallel Sorting Algorithms
    Comparison of parallel sorting algorithms Darko Božidar and Tomaž Dobravec Faculty of Computer and Information Science, University of Ljubljana, Slovenia Technical report November 2015 TABLE OF CONTENTS 1. INTRODUCTION .................................................................................................... 3 2. THE ALGORITHMS ................................................................................................ 3 2.1 BITONIC SORT ........................................................................................................................ 3 2.2 MULTISTEP BITONIC SORT ................................................................................................. 3 2.3 IBR BITONIC SORT ................................................................................................................ 3 2.4 MERGE SORT .......................................................................................................................... 4 2.5 QUICKSORT ............................................................................................................................ 4 2.6 RADIX SORT ........................................................................................................................... 4 2.7 SAMPLE SORT ........................................................................................................................ 4 3. TESTING ENVIRONMENT .................................................................................... 5 4. RESULTS ................................................................................................................
    [Show full text]
  • Discussion 10 Solution Fall 2015 1 Sorting I Show the Steps Taken by Each Sort on the Following Unordered List
    CS 61B Discussion 10 Solution Fall 2015 1 Sorting I Show the steps taken by each sort on the following unordered list: 106, 351, 214, 873, 615, 172, 333, 564 (a) Quicksort (assume the pivot is always the first item in the sublist being sorted and the array is sorted in place). At every step circle everything that will be a pivot on the next step and box all previous pivots. 106 351 214 873 615 172 333 564 £ 106 351 214 873 615 172 333 564 ¢ ¡ £ 106 214 172 333 351 873 615 564 £¢ ¡ £ 106 172 214 333 351 615 564 873 ¢ ¡ £¢ ¡ 106 172 214 333 351 564 615 873 ¢ ¡ (b) Merge sort. Show the intermediate merging steps. 106 351 214 873 615 172 333 564 106 351 214 873 172 615 333 564 106 214 351 873 172 333 564 615 106 214 351 873 172 333 564 615 106 172 214 333 351 564 615 873 (c) LSD radix sort. 106 351 214 873 615 172 333 564 351 172 873 333 214 564 615 106 106 214 615 333 351 564 172 873 106 172 214 333 351 564 615 873 2 Sorting II Match the sorting algorithms to the sequences, each of which represents several intermediate steps in the sorting of an array of integers. Algorithms: Quicksort, merge sort, heapsort, MSD radix sort, insertion sort. CS 61B, Fall 2015, Discussion 10 Solution 1 (a) 12, 7, 8, 4, 10, 2, 5, 34, 14 7, 8, 4, 10, 2, 5, 12, 34, 14 4, 2, 5, 7, 8, 10, 12, 14, 34 Quicksort (b) 23, 45, 12, 4, 65, 34, 20, 43 12, 23, 45, 4, 65, 34, 20, 43 Insertion sort (c) 12, 32, 14, 11, 17, 38, 23, 34 12, 14, 11, 17, 23, 32, 38, 34 MSD radix sort (d) 45, 23, 5, 65, 34, 3, 76, 25 23, 45, 5, 65, 3, 34, 25, 76 5, 23, 45, 65, 3, 25, 34, 76 Merge sort (e) 23, 44, 12, 11, 54, 33, 1, 41 54, 44, 33, 41, 23, 12, 1, 11 44, 41, 33, 11, 23, 12, 1, 54 Heap sort 3 Runtimes Fill in the best and worst case runtimes of the following sorting algorithms with respect to n, the length of the list being sorted, along with when that runtime would occur.
    [Show full text]
  • A Comparative Study of Sorting Algorithms Comb, Cocktail and Counting Sorting
    International Research Journal of Engineering and Technology (IRJET) e‐ISSN: 2395 ‐0056 Volume: 04 Issue: 01 | Jan ‐2017 www.irjet.net p‐ISSN: 2395‐0072 A comparative Study of Sorting Algorithms Comb, Cocktail and Counting Sorting Ahmad H. Elkahlout1, Ashraf Y. A. Maghari2. 1 Faculty of Information Technology, Islamic University of Gaza ‐ Palestine 2 Faculty of Information Technology, Islamic University of Gaza ‐ Palestine ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐***‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ Abstract –The sorting algorithms problem is probably one java programming language, in which every algorithm sort of the most famous problems that used in abroad variety of the same set of random numeric data. Then the execution time during the sorting process is measured for each application. There are many techniques to solve the sorting algorithm. problem. In this paper, we conduct a comparative study to evaluate the performance of three algorithms; comb, cocktail The rest part of this paper is organized as follows. Section 2 and count sorting algorithms in terms of execution time. Java gives a background of the three algorithms; comb, count, and programing is used to implement the algorithms using cocktail algorithms. In section 3, related work is presented. numeric data on the same platform conditions. Among the Section4 comparison between the algorithms; section 5 three algorithms, we found out that the cocktail algorithm has discusses the results obtained from the evaluation of sorting the shortest execution time; while counting sort comes in the techniques considered. The paper is concluded in section 6. second order. Furthermore, Comb comes in the last order in term of execution time. Future effort will investigate the 2.
    [Show full text]
  • Register Level Sort Algorithm on Multi-Core SIMD Processors
    Register Level Sort Algorithm on Multi-Core SIMD Processors Tian Xiaochen, Kamil Rocki and Reiji Suda Graduate School of Information Science and Technology The University of Tokyo & CREST, JST {xchen, kamil.rocki, reiji}@is.s.u-tokyo.ac.jp ABSTRACT simultaneously. GPU employs a similar architecture: single- State-of-the-art hardware increasingly utilizes SIMD paral- instruction-multiple-threads(SIMT). On K20, each SMX has lelism, where multiple processing elements execute the same 192 CUDA cores which act as individual threads. Even a instruction on multiple data points simultaneously. How- desktop type multi-core x86 platform such as i7 Haswell ever, irregular and data intensive algorithms are not well CPU family supports AVX2 instruction set (256 bits). De- suited for such architectures. Due to their importance, it veloping algorithms that support multi-core SIMD architec- is crucial to obtain efficient implementations. One example ture is the precondition to unleash the performance of these of such a task is sort, a fundamental problem in computer processors. Without exploiting this kind of parallelism, only science. In this paper we analyze distinct memory accessing a small fraction of computational power can be utilized. models and propose two methods to employ highly efficient Parallel sort as well as sort in general is fundamental and bitonic merge sort using SIMD instructions as register level well studied problem in computer science. Algorithms such sort. We achieve nearly 270x speedup (525M integers/s) on as Bitonic-Merge Sort or Odd Even Merge Sort are widely a 4M integer set using Xeon Phi coprocessor, where SIMD used in practice.
    [Show full text]
  • Different Sorting Algorithm's Comparison Based Upon the Time
    International Journal of u- and e- Service, Science and Technology Vol.9, No. 8 (2016), pp.287-296 http://dx.doi.org/10.14257/ijunesst.2016.9.8.24 Different Sorting Algorithm’s Comparison based Upon the Time Complexity D. Rajagopal1* and K. Thilakavalli2 1Assistant Professor, Department of Computer Applications, KSR College of Arts and Science(Autonomous), Tiruchengode, Namakkal Dt, Tamilnadu, India 2Assistant Professor, Department of Computer Applications, KSR College of Arts and Science(Autonomous), Tiruchengode, Namakkal Dt, Tamilnadu, India [email protected],[email protected] Abstract In this paper the different sorting algorithms execution time has been examined with different number of elements. Through this experimental result concluded that the algorithm which is working best. The analysis, execution time has analyzed, tabulated in Microsoft Excel. The sorting problem has attracted a great deal of study, possibly due to the complexity of solving it proficiently despite its simple, familiar statement. Sorting algorithms are established in opening computer science classes, where the abundance of algorithms for the problem provides a gentle beginning to variety of core algorithm concepts. Objective of this paper is finding the best sorting algorithm. Keywords: Sorting algorithm, Time Complexity, Efficiency, Execution Time, Quick Sort, Selection Sort 1. Introduction Sorting algorithm is an algorithm in that the most-used orders are numerical order and lexicographical order in computer science and mathematics. Proficient sorting is vital for optimizing the utilization of other algorithms that require sorted lists to work correctly. More properly, the output must gratify two circumstances: (1) The output is in non decreasing order and (2) The output is a variation, or reordering, of the input.
    [Show full text]
  • 7 Internal Sorting and Quicksort) by Taking Advantage of the Best Case Behavior of Another Algorithm (Insertion Sort)
    7 Internal Sorting We sort many things in our everyday lives: A handful of cards when playing Bridge; bills and other piles of paper; jars of spices; and so on. And we have many intuitive strategies that we can use to do the sorting, depending on how many objects we have to sort and how hard they are to move around. Sorting is also one of the most frequently performed computing tasks. We might sort the records in a database so that we can search the collection efficiently. We might sort the records by zip code so that we can print and mail them more cheaply. We might use sorting as an intrinsic part of an algorithm to solve some other problem, such as when computing the minimum-cost spanning tree (see Section 11.5). Because sorting is so important, naturally it has been studied intensively and many algorithms have been devised. Some of these algorithms are straightforward adaptations of schemes we use in everyday life. Others are totally alien to how hu- mans do things, having been invented to sort thousands or even millions of records stored on the computer. After years of study, there are still unsolved problems related to sorting. New algorithms are still being developed and refined for special- purpose applications. While introducing this central problem in computer science, this chapter has a secondary purpose of illustrating many important issues in algorithm design and analysis. The collection of sorting algorithms presented will illustate that divide- and-conquer is a powerful approach to solving a problem, and that there are multi- ple ways to do the dividing.
    [Show full text]