Algorithms and Applications • Sorting Algorithms • Numerical Algorithms • Image Processing • Searching and Optimization

Total Page:16

File Type:pdf, Size:1020Kb

Algorithms and Applications • Sorting Algorithms • Numerical Algorithms • Image Processing • Searching and Optimization Slide 1 Slide 2 Areas done in textbook: Algorithms and Applications • Sorting Algorithms • Numerical Algorithms • Image Processing • Searching and Optimization ã Barry Wilkinson 2003. This material is for sole and exclusive use of students enrolled at Western Carolina University. It is not to be sold, reproduced, or generally distributed. ã Barry Wilkinson 2003. This material is for sole and exclusive use of students enrolled at Western Carolina University. It is not to be sold, reproduced, or generally distributed. Slide 3 Slide 4 Chapter 10 Potential Speedup O(nlogn) optimal for any sequential sorting algorithm without using special properties of the numbers. Sorting Algorithms Best we can expect based upon a sequential sorting algorithm using n processors is - rearranging a list of numbers into increasing (strictly non- decreasing) order. O(nlogn ) Optimal parallel time complexity = ------------------------- = O(logn ) n Has been obtained but the constant hidden in the order notation extremely large. ã Barry Wilkinson 2003. This material is for sole and exclusive use of students enrolled at Western Carolina University. It is not to be sold, reproduced, or generally distributed. ã Barry Wilkinson 2003. This material is for sole and exclusive use of students enrolled at Western Carolina University. It is not to be sold, reproduced, or generally distributed. Slide 5 Slide 6 Compare-and-Exchange Sorting Algorithms Message-Passing Compare and Exchange Compare and Exchange Version 1 Form the basis of several, if not most, classical sequential sorting P1 sends A to P2, which compares A and B and sends back B to P1 algorithms. if A is larger than B (otherwise it sends back A to P1): Sequence of steps Two numbers, say A and B, are compared. If A > B, A and B are P P 1 1 2 exchanged, i.e.: A Send(A) B If A > B send(B) else send(A) If A > B load A if (A > B) { 2 else load B temp = A; Compare 3 A = B; B = temp; } ã Barry Wilkinson 2003. This material is for sole and exclusive use of students enrolled at Western Carolina University. It is not to be sold, reproduced, or generally distributed. ã Barry Wilkinson 2003. This material is for sole and exclusive use of students enrolled at Western Carolina University. It is not to be sold, reproduced, or generally distributed. Slide 7 Slide 8 Alternative Message Passing Method Note on Precision of Duplicated Computations Version 2 For P1 to send A to P2 and P2 to send B to P1. Then both processes Previous code assumes that the if condition, A > B, will return the perform compare operations. P1 keeps the larger of A and B and P2 same Boolean answer in both processors. keeps the smaller of A and B: Different processors operating at different precision could P P 1 1 2 conceivably produce different answers if real numbers are being A Send(A) B compared. Send(B) 2 If A > B load A This situation applies to anywhere computations are duplicated in Compare Compare 3 If A > B load B different processors to reduce message passing, or to make the 3 code SPMD. ã Barry Wilkinson 2003. This material is for sole and exclusive use of students enrolled at Western Carolina University. It is not to be sold, reproduced, or generally distributed. ã Barry Wilkinson 2003. This material is for sole and exclusive use of students enrolled at Western Carolina University. It is not to be sold, reproduced, or generally distributed. Slide 9 Slide 10 Data Partitioning Merging Two Sublists — Version 2 (Version 1) p processors and n numbers. n/p numbers assigned to each P1 P2 Original processor: Merge numbers Merge Original 98 98 numbers 98 98 Keep 88 80 80 88 higher 80 43 43 80 numbers P1 P2 42 42 (final 50 50 numbers) Keep 43 43 Merge lower 88 Original 88 42 50 numbers 50 42 88 88 numbers 28 28 98 Keep (final 28 28 Original 50 50 88 numbers) 25 25 25 25 numbers 28 28 higher 80 numbers 25 25 50 43 43 98 Return 42 80 42 Final Original 28 lower numbers 28 numbers 43 numbers 25 42 25 ã Barry Wilkinson 2003. This material is for sole and exclusive use of students enrolled at Western Carolina University. It is not to be sold, reproduced, or generally distributed. ã Barry Wilkinson 2003. This material is for sole and exclusive use of students enrolled at Western Carolina University. It is not to be sold, reproduced, or generally distributed. Slide 11 Slide 12 Original sequence: 4 2 7 8 5 1 3 6 4 2 7 8 5 1 3 6 Bubble Sort 2 4 7 8 5 1 3 6 2 4 7 8 5 1 3 6 Phase 1 First, largest number moved to the end of list by a series of Place 2 4 7 8 5 1 3 6 largest number compares and exchanges, starting at the opposite end. 2 4 7 5 8 1 3 6 2 4 7 5 1 8 3 6 Actions repeated with subsequent numbers, stopping just before 2 4 7 5 1 3 8 6 the previously positioned number. 2 4 7 5 1 3 6 8 2 4 7 5 1 3 6 8 Phase 2 Place 2 4 7 5 1 3 6 8 In this way, the larger numbers move (“bubble”) toward one end, next largest 2 4 5 7 1 3 6 8 number Time ã Barry Wilkinson 2003. This material is for sole and exclusive use of students enrolled at Western Carolina University. It is not to be sold, reproduced, or generally distributed. ã Barry Wilkinson 2003. This material is for sole and exclusive use of students enrolled at Western Carolina University. It is not to be sold, reproduced, or generally distributed. Slide 13 Slide 14 Parallel Bubble Sort Iteration could start before previous iteration finished if does not overtake previous bubbling action: Phase 1 Time Complexity 1 n – 1 n(n – 1) 1 Number of compare and exchange operations = i = å -------------------- Phase 2 i = 1 2 2 1 Indicates a time complexity of O(n2) given that a single compare- Time 2 1 and-exchange operation has a constant complexity, O(1). Phase 3 3 2 1 3 2 1 Phase 4 4 3 2 1 ã Barry Wilkinson 2003. This material is for sole and exclusive use of students enrolled at Western Carolina University. It is not to be sold, reproduced, or generally distributed. ã Barry Wilkinson 2003. This material is for sole and exclusive use of students enrolled at Western Carolina University. It is not to be sold, reproduced, or generally distributed. Slide 15 Slide 16 Odd-Even Transposition Sort Odd-Even (Transposition) Sort Sorting eight numbers Variation of bubble sort. P0 P1 P2 P3 P4 P5 P6 P7 Step Operates in two alternating phases, even phase and odd phase. 0 4 2 7 8 5 1 3 6 1 2 4 7 8 1 5 3 6 Even phase 2 2 4 7 1 8 3 5 6 3 2 4 1 7 3 8 5 6 Even-numbered processes exchange numbers with their right neighbor. Time 4 2 1 4 3 7 5 8 6 5 1 2 3 4 5 7 6 8 Odd phase 6 1 2 3 4 5 6 7 8 Odd-numbered processes exchange numbers with their right 7 1 2 3 4 5 6 7 8 neighbor. ã Barry Wilkinson 2003. This material is for sole and exclusive use of students enrolled at Western Carolina University. It is not to be sold, reproduced, or generally distributed. ã Barry Wilkinson 2003. This material is for sole and exclusive use of students enrolled at Western Carolina University. It is not to be sold, reproduced, or generally distributed. Slide 17 Slide 18 Parallelizing Mergesort Using tree allocation of processes Mergesort Unsorted list 4 2 7 8 5 1 3 6 P0 A classical sequential sorting algorithm using divide-and-conquer 4 2 7 8 5 1 3 6 P P approach. Unsorted list first divided into half. Each half is again Divide 0 4 list divided into two. Continued until individual numbers are obtained. 4 2 7 8 5 1 3 6 P0 P2 P4 P6 4 2 7 8 5 1 3 6 P P P P P P P P Then pairs of numbers combined (merged) into sorted list of two 0 1 2 3 4 5 6 7 numbers. Pairs of these lists of four numbers are merged into sorted 2 4 7 8 1 5 3 6 P0 P2 P4 P6 lists of eight numbers. This is continued until the one fully sorted list Merge 2 4 7 8 1 3 5 6 P0 P4 is obtained. 1 2 3 4 5 6 7 8 P0 Sorted list Process allocation ã Barry Wilkinson 2003. This material is for sole and exclusive use of students enrolled at Western Carolina University. It is not to be sold, reproduced, or generally distributed. ã Barry Wilkinson 2003. This material is for sole and exclusive use of students enrolled at Western Carolina University. It is not to be sold, reproduced, or generally distributed. Slide 19 Slide 20 Quicksort Analysis Very popular sequential sorting algorithm that performs well with an average sequential time complexity of O(nlogn). Sequential First list divided into two sublists. All the numbers in one sublist Sequential time complexity is O(nlogn). arranged to be smaller than all the numbers in the other sublist. Achieved by first selecting one number, called a pivot, against which Parallel every other number is compared.
Recommended publications
  • Can We Overcome the Nlog N Barrier for Oblivious Sorting?
    Can We Overcome the n log n Barrier for Oblivious Sorting? ∗ Wei-Kai Lin y Elaine Shi z Tiancheng Xie x Abstract It is well-known that non-comparison-based techniques can allow us to sort n elements in o(n log n) time on a Random-Access Machine (RAM). On the other hand, it is a long-standing open question whether (non-comparison-based) circuits can sort n elements from the domain [1::2k] with o(kn log n) boolean gates. We consider weakened forms of this question: first, we consider a restricted class of sorting where the number of distinct keys is much smaller than the input length; and second, we explore Oblivious RAMs and probabilistic circuit families, i.e., computational models that are somewhat more powerful than circuits but much weaker than RAM. We show that Oblivious RAMs and probabilistic circuit families can sort o(log n)-bit keys in o(n log n) time or o(kn log n) circuit complexity. Our algorithms work in the indivisible model, i.e., not only can they sort an array of numerical keys | if each key additionally carries an opaque ball, our algorithms can also move the balls into the correct order. We further show that in such an indivisible model, it is impossible to sort Ω(log n)-bit keys in o(n log n) time, and thus the o(log n)-bit-key assumption is necessary for overcoming the n log n barrier. Finally, after optimizing the IO efficiency, we show that even the 1-bit special case can solve open questions: our oblivious algorithms solve tight compaction and selection with optimal IO efficiency for the first time.
    [Show full text]
  • CS 758/858: Algorithms
    CS 758/858: Algorithms ■ COVID Prof. Wheeler Ruml Algorithms TA Sumanta Kashyapi This Class Complexity http://www.cs.unh.edu/~ruml/cs758 4 handouts: course info, schedule, slides, asst 1 2 online handouts: programming tips, formulas 1 physical sign-up sheet/laptop (for grades, piazza) Wheeler Ruml (UNH) Class 1, CS 758 – 1 / 25 COVID ■ COVID Algorithms This Class Complexity ■ check your Wildcat Pass before coming to campus ■ if you have concerns, let me know Wheeler Ruml (UNH) Class 1, CS 758 – 2 / 25 ■ COVID Algorithms ■ Algorithms Today ■ Definition ■ Why? ■ The Word ■ The Founder This Class Complexity Algorithms Wheeler Ruml (UNH) Class 1, CS 758 – 3 / 25 Algorithms Today ■ ■ COVID web: search, caching, crypto Algorithms ■ networking: routing, synchronization, failover ■ Algorithms Today ■ machine learning: data mining, recommendation, prediction ■ Definition ■ Why? ■ bioinformatics: alignment, matching, clustering ■ The Word ■ ■ The Founder hardware: design, simulation, verification ■ This Class business: allocation, planning, scheduling Complexity ■ AI: robotics, games Wheeler Ruml (UNH) Class 1, CS 758 – 4 / 25 Definition ■ COVID Algorithm Algorithms ■ precisely defined ■ Algorithms Today ■ Definition ■ mechanical steps ■ Why? ■ ■ The Word terminates ■ The Founder ■ input and related output This Class Complexity What might we want to know about it? Wheeler Ruml (UNH) Class 1, CS 758 – 5 / 25 Why? ■ ■ COVID Computer scientist 6= programmer Algorithms ◆ ■ Algorithms Today understand program behavior ■ Definition ◆ have confidence in results, performance ■ Why? ■ The Word ◆ know when optimality is abandoned ■ The Founder ◆ solve ‘impossible’ problems This Class ◆ sets you apart (eg, Amazon.com) Complexity ■ CPUs aren’t getting faster ■ Devices are getting smaller ■ Software is the differentiator ■ ‘Software is eating the world’ — Marc Andreessen, 2011 ■ Everything is computation Wheeler Ruml (UNH) Class 1, CS 758 – 6 / 25 The Word: Ab¯u‘Abdall¯ah Muh.ammad ibn M¯us¯aal-Khw¯arizm¯ı ■ COVID 780-850 AD Algorithms Born in Uzbekistan, ■ Algorithms Today worked in Baghdad.
    [Show full text]
  • Investigating the Effect of Implementation Languages and Large Problem Sizes on the Tractability and Efficiency of Sorting Algorithms
    International Journal of Engineering Research and Technology. ISSN 0974-3154, Volume 12, Number 2 (2019), pp. 196-203 © International Research Publication House. http://www.irphouse.com Investigating the Effect of Implementation Languages and Large Problem Sizes on the Tractability and Efficiency of Sorting Algorithms Temitayo Matthew Fagbola and Surendra Colin Thakur Department of Information Technology, Durban University of Technology, Durban 4000, South Africa. ORCID: 0000-0001-6631-1002 (Temitayo Fagbola) Abstract [1],[2]. Theoretically, effective sorting of data allows for an efficient and simple searching process to take place. This is Sorting is a data structure operation involving a re-arrangement particularly important as most merge and search algorithms of an unordered set of elements with witnessed real life strictly depend on the correctness and efficiency of sorting applications for load balancing and energy conservation in algorithms [4]. It is important to note that, the rearrangement distributed, grid and cloud computing environments. However, procedure of each sorting algorithm differs and directly impacts the rearrangement procedure often used by sorting algorithms on the execution time and complexity of such algorithm for differs and significantly impacts on their computational varying problem sizes and type emanating from real-world efficiencies and tractability for varying problem sizes. situations [5]. For instance, the operational sorting procedures Currently, which combination of sorting algorithm and of Merge Sort, Quick Sort and Heap Sort follow a divide-and- implementation language is highly tractable and efficient for conquer approach characterized by key comparison, recursion solving large sized-problems remains an open challenge. In this and binary heap’ key reordering requirements, respectively [9].
    [Show full text]
  • Counting Sort and Radix Sort
    Counting sort and radix sort Nick Smallbone December 11, 2018 Radix sort is the oldest sorting algorithm which is still in general use; it predates the computer. On the left is Herman Hollerith, the inventor of radix sort. In the late 1800s, he built enormous electromechanical machines which used radix sort to tabulate US census data; he set up a company to sell the machines, and the company later became IBM. On the right you can see a 1950s IBM sorting machine running the radix sort algorithm. Radix sort is unlike the sorting algorithms we have seen so far, in that it is not based on comparisons (≤). However, it only works on certain kinds of data – it is mainly used on numerical data, and is often faster than comparison-based sorting algorithms. Before seeing radix sort, we will look at a simpler algorithm, counting sort. 1 Counting sort #1: sorting a list of digits Suppose you want to sort the first 100 digits of π, in ascending order, by hand. How would you do it? 31415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679 Counting sort is one approach to sorting lists of digits. It can be carried out by hand or on a computer. The idea is like this. First we count how many times each digit occurs in the input data (in this case, the first 100 digits of π): Digit 0 1 2 3 4 5 6 7 8 9 Number of occurrences 8 8 12 12 10 8 9 8 12 14 We can compute this table while looking through the input list only once, by keeping a running total for each digit.
    [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 Algorithms
    Sorting Algorithms Next to storing and retrieving data, sorting of data is one of the more common algorithmic tasks, with many different ways to perform it. Whenever we perform a web search and/or view statistics at some website, the presented data has most likely been sorted in some way. In this lecture and in the following lectures we will examine several different ways of sorting. The following are some reasons for investigating several of the different algorithms (as opposed to one or two, or the \best" algorithm). • There exist very simply understood algorithms which, although for large data sets behave poorly, perform well for small amounts of data, or when the range of the data is sufficiently small. • There exist sorting algorithms which have shown to be more efficient in practice. • There are still yet other algorithms which work better in specific situations; for example, when the data is mostly sorted, or unsorted data needs to be merged into a sorted list (for example, adding names to a phonebook). 1 Counting Sort Counting sort is primarily used on data that is sorted by integer values which fall into a relatively small range (compared to the amount of random access memory available on a computer). Without loss of generality, we can assume the range of integer values is [0 : m], for some m ≥ 0. Now given array a[0 : n − 1] the idea is to define an array of lists l[0 : m], scan a, and, for i = 0; 1; : : : ; n − 1 store element a[i] in list l[v(a[i])], where v is the function that computes an array element's sorting value.
    [Show full text]
  • Evaluation of Sorting Algorithms, Mathematical and Empirical Analysis of Sorting Algorithms
    International Journal of Scientific & Engineering Research Volume 8, Issue 5, May-2017 86 ISSN 2229-5518 Evaluation of Sorting Algorithms, Mathematical and Empirical Analysis of sorting Algorithms Sapram Choudaiah P Chandu Chowdary M Kavitha ABSTRACT:Sorting is an important data structure in many real life applications. A number of sorting algorithms are in existence till date. This paper continues the earlier thought of evolutionary study of sorting problem and sorting algorithms concluded with the chronological list of early pioneers of sorting problem or algorithms. Latter in the study graphical method has been used to present an evolution of sorting problem and sorting algorithm on the time line. An extensive analysis has been done compared with the traditional mathematical methods of ―Bubble Sort, Selection Sort, Insertion Sort, Merge Sort, Quick Sort. Observations have been obtained on comparing with the existing approaches of All Sorts. An “Empirical Analysis” consists of rigorous complexity analysis by various sorting algorithms, in which comparison and real swapping of all the variables are calculatedAll algorithms were tested on random data of various ranges from small to large. It is an attempt to compare the performance of various sorting algorithm, with the aim of comparing their speed when sorting an integer inputs.The empirical data obtained by using the program reveals that Quick sort algorithm is fastest and Bubble sort is slowest. Keywords: Bubble Sort, Insertion sort, Quick Sort, Merge Sort, Selection Sort, Heap Sort,CPU Time. Introduction In spite of plentiful literature and research in more dimension to student for thinking4. Whereas, sorting algorithmic domain there is mess found in this thinking become a mark of respect to all our documentation as far as credential concern2.
    [Show full text]
  • 6.006 Introduction to Algorithms Spring 2008
    MIT OpenCourseWare http://ocw.mit.edu 6.006 Introduction to Algorithms Spring 2008 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. Lecture 11 Sorting IV: Stable Sorting, Radix Sort 6.006 Spring 2008 Lecture 11: Sorting IV: Stable Sorting, Radix Sort Lecture Overview • Stable Sorting • Radix Sort • Quick Sort not officially a part of 6:006 • Sorting Races Stable Sorting Preserves input order among equal elements 4’ 1 3* 4 3 counting sort is stable merge sort is stable 1 3* 3 4’ 4 Figure 1: Stability Selection Sort and Heap: Find maximum element and put it at end of array (swap with element at end of array) NOT STABLE! ← define 3 2a 2b 2b 2a 3 2a <2b Figure 2: Selection Sort Instability Radix Sort • Herman Hollerith card-sorting machine for 1890 census. • Digit by Digit sort by mechanical machine 1. Examine given column of each card in a deck 2. Distribute the card into one of 10 bins 1 Lecture 11 Sorting IV: Stable Sorting, Radix Sort 6.006 Spring 2008 3. Gather cards bin by bin, so cards with first place punched are on top of cards with second place punched, etc. 80 cols . 10 . places . Figure 3: Punch Card MSB vs. LSB? Sort on most significant digit first or least significant digit first? MSB strategy: Cards in 9 of 10 bins must be put aside, leading to a large number of intermediate piles LSB strategy: Can gather sorted cards in bins appropriately to create a deck! Example 3 2 9 7 2 0 7 2 0 3 2 9 4 5 7 3 5 5 3 2 9 3 5 5 6 5 7 4 3 6 4 3 6 4 3 6 8 3 9 4 5 7 8 3 9 4 5 7 4 3 6 6 5 7 3 5 5 6 5 7 7 2 0 3 2 9 4 5 7 7 2 0 3 5 5 8 3 9 6 5 7 8 3 9 Digit sort needs to be stable, else will get wrong result! Figure 4: Example of Radix Sort 2 Lecture 11 Sorting IV: Stable Sorting, Radix Sort 6.006 Spring 2008 Analysis Assume counting sort is auxiliary stable sort.
    [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]
  • 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]
  • 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]