An in-depth analysis of various parallel sorting algorithms, including odd-even sorting network, odd-even transposition, and merge-split for linear array. It explains their architectures, time complexities, and comparator requirements. The document also includes a step-by-step example of quicksort, a sequential sorting algorithm, to illustrate the concepts. This study guide is essential for students and researchers interested in parallel computing and sorting algorithms.
Download Parallel Sorting Algorithms and more Study Guides, Projects, Research Data Structures and Algorithms in PDF only on Docsity!
Sorting Algorithm
Algorithms & Parallel Processing
Informatics Engineering
Gunadarma University
Introduction to Sorting
Importance : Sorting is a fundamental computational task that has been extensively studied and is crucial for many applications.
Problem Definition : Given a sequence S = (s 1 , s 2 , ..., sn) of n items in random order, sort them into a sequence S′ = (s 1 ′, s 2 ′, ..., sn′) such that s′i≤s′i+1.
Sequential Sorting Lower Bound : Any sorting algorithm requires Ω(n logn) operations in the worst case. Sequential Sorting : Quicksort
Quicksort Algorithm :
Base Case : If the sequence has one or two elements, sort directly.
Recursive Case : ▪ Select the median element. ▪ Split the sequence into two subsequences: one with elements less than or equal to the median, and one with elements greater than or equal to the median. ▪ Recursively apply Quicksort to both subsequences.
Time Complexity : Optimal with O(n logn).
Merge-Split for Linear Array
Algorithm :
Each processor sorts its subsequence using Quicksort.
Odd-numbered processors merge their subsequences with their even-numbered neighbors and split the merged sequence.
Repeat for ⌈ N /2⌉ iterations, where N is the number of processors.
Time Complexity : O((n logn)/ N ) + O( n ), aiming for cost-optimality. Example : Quicksort Problem : Sort the sequence S = (6, 5, 9, 2, 4, 3, 5, 1, 7, 5, 8). Step-by-Step Execution :
Initial Call : S = (6, 5, 9, 2, 4, 3, 5, 1, 7, 5, 8) o Median : 5 o Split : S 1 = (2, 4, 3, 1, 5, 5), S2 = (6, 9, 7, 8, 5)
First Recursive Call onS 1 : o Median : 3 o Split : S 11 = (2, 1 ), S 12 = (4, 5, 5)
Recursive Calls onS11 andS12 : o S 11 : Sorted to (1, 2) o S 12 : Median 5, Split S 121 = (4), S 122 = (5, 5)
Recursive Calls onS121 andS122 : o Both already sorted. o Combined : (1, 2, 3, 4, 5, 5)
First Recursive Call onS2 : o Median : 7 o Split: S 21 = (6, 5), S 22 = (9,8)
Recursive Calls onS21 andS 22 : o S 21 : Median 5, Split S 211 = (5), S 212 = (6) o S 22 : Median 8, Split S 221 = (8), S 222 = (9)
Combining Sorted Subsequences : o S 1 and S 2 result in : (1, 2, 3, 4, 5, 5, 5, 6, 7, 8, 9) This results in the final sorted sequence : (1, 2, 3, 4, 5 , 5, 5, 6, 7, 8, 9). This study guide covers the essential concepts and algorithms related to sorting in parallel computing, providing both theoretical background and practical examples.