Presentation is loading. Please wait.

Presentation is loading. Please wait.

Sorting an Intransitive Total Ordered Set Sequential and Parallel Implementation for COMP 5704 Parallel Algorithms by Johannes Singler, Carleton University.

Similar presentations


Presentation on theme: "Sorting an Intransitive Total Ordered Set Sequential and Parallel Implementation for COMP 5704 Parallel Algorithms by Johannes Singler, Carleton University."— Presentation transcript:

1 Sorting an Intransitive Total Ordered Set Sequential and Parallel Implementation for COMP 5704 Parallel Algorithms by Johannes Singler, Carleton University

2 Presentation Outline Introduction to the Problem Prerequisites Sequential Algorithm Parallelizing for a PRAM Questions?!

3 Introduction Definition of Transitivity: Traditional sorting relies upon (Transitive) Total Ordered Set (e. g. natural numbers and ≥). New Problem: Sorting of Intransitive Total Ordered Set (ITOS) Relying on intransitive relation

4 Intransitive Sorted Sequence An intransitive sorted sequence has to satisfy: Theorem: There exists always a solution (proof later if time remaining). The solution is not unique in general. Real-world example for an ITOS: tournament in sports: Every player wins or loses against each other. Therefore ITOS also referred to as a Tournament.

5 Representation as a Graph Tournament can be represented as a complete directed graph. Every two nodes are connected by an edge, direction denotes relation (who wins). A intransitive sorted sequence then corresponds to a Hamiltonian Path. Definition of Hamiltonian Path: A path in a graph that visits every node exactly once.

6 Sorting Prerequisites Sorting using Semi-Heap according to Wu [2] Definition of On 3 elements. Set in general (not unique any more). If one player beats both the others, he is the only maximum element, otherwise all three are maximal. Definition of a Semi-Heap Binary tree (complete in the beginning). Similar to a heap. Semi-Heap condition: 4 valid possibilities (and 4 invalid):

7 Actual Sorting Similar to Heap-Sort Build up heap Iteratively remove root, replace by rightmost leaf of deepest level before pushing this down the heap. Intransitive Sorting using Semi-Heap Build up semi-heap Iteratively remove root, update semi-heap top-down. Tree may not be complete any more after first removal.

8 Pseudo-Code Pseudo-Code: semi-heap-sort build-semi-heap While nodes left Remove root and append to sorted sequence Recursively replace by winning child top-down build-semi-heap (  (n)) for i:=heapsize/2 downto 1 semi-heapify(i) semi-heapify(i) if(i not max) exchange with max child semi-heapify(former child position) recursively

9 Sequential Complexity Demo Sequential Complexity: O(n log n)

10 Parallelizing the Algorithm for a PRAM Parallelizing for fine-grained multiprocessing using Pipelining. One processor per two consecutive tree levels (overlapping):  (log n) processors needed. Two phases: Either processors with even numbers or processor with odd numbers are active. While updating the tree top-down, the work is handed from one processor to the next. Demo

11 Complexity Issues Parallel Complexity:  (n) on an EREW PRAM using  (log n) processors, therefore cost-optimal. Building the initial semi-heap takes  (n) sequentially and thus needs no parallelization. No concurrent access needed because of phases. Can be modified to use less processors according to Brent’s Law.

12 Outlook Extension: A Hamiltonian Cycle exists in every strong connected Tournament. Definition of strong connected: Every node is reachable from each other Hamiltonian Cycle: Every node is visited exactly once and there is an edge from the last node to the first one:

13 Questions? Do you have any questions left?

14 Questions! Which of the following subtrees satisfy the semi-heap condition? What does Pipelining mean? How many possible tournaments of size n are there?

15 Conclusion Presentation and demo program available at my website: References [1] Danny Soroker. Fast parallel algorithms for finding Hamiltonian paths and cycles in a tournament. Journal of Algorithms, 9(2):276–286, June [2] J. Wu. On sorting an intransitive total ordered set using semi- heap. In International Parallel and Distributed Processing Symposium, pages 257–262, 2000.

16 Appendix: Proof of Theorem By induction according to Soroker [1] Result clear for n=2 n → n+1 Let v be vertex of V(T), then V(T)-{v} has Hamiltonian Path v 1,…,v n If v → v 1, then v,v 1,…,v n is a valid result Otherwise let I be the largest index such that v i → v, then v 1,…,v i,v,v i+1,…,v n or v 1,…,v n,v respectively (i=n) is a valid result.


Download ppt "Sorting an Intransitive Total Ordered Set Sequential and Parallel Implementation for COMP 5704 Parallel Algorithms by Johannes Singler, Carleton University."

Similar presentations


Ads by Google