160 likes | 292 Vues
This presentation explores an innovative framework for sorting Intransitive Total Ordered Sets (ITOS), a challenge distinct from traditional transitive sorting. The approach employs a semi-heap structure to facilitate efficient sorting, addressing real-world scenarios like sports tournaments where outcomes are non-transitive. The presentation covers the sequential algorithm, its effective parallelization for PRAM systems, and delves into complexities, demonstrating that the semi-heap sorting maintains optimal performance. Additionally, we explore the existence of Hamiltonian paths in tournaments and engage in a thoughtful Q&A segment to clarify key concepts.
E N D
Sorting an Intransitive Total Ordered Set Sequential and Parallel Implementation for COMP 5704 Parallel Algorithms by Johannes Singler, Carleton University
Presentation Outline • Introduction to the Problem • Prerequisites • Sequential Algorithm • Parallelizing for a PRAM • Questions?!
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
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.
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.
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):
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.
Pseudo-Code • Pseudo-Code: • semi-heap-sortbuild-semi-heapWhile nodes left Remove root and append to sorted sequence Recursively replace by winning child top-down • build-semi-heap (Q(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
Sequential Complexity • Demo • Sequential Complexity: O(n log n)
Parallelizing the Algorithm for a PRAM • Parallelizing for fine-grained multiprocessing using Pipelining. • One processor per two consecutive tree levels (overlapping): Q(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
Complexity Issues • Parallel Complexity: • Q(n) on an EREW PRAM using Q(log n) processors, therefore cost-optimal. • Building the initial semi-heap takes Q(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.
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:
Questions? • Do you have any questions left?
Questions! • Which of the following subtrees satisfy the semi-heap condition? • What does Pipelining mean? • How many possible tournaments of size n are there?
Conclusion • Presentation and demo program available at my website: http://www.jsingler.de/COMP5704/ • References[1] Danny Soroker. Fast parallel algorithms for finding Hamiltonian paths and cycles in a tournament. Journal of Algorithms, 9(2):276–286, June 1988.[2] J. Wu. On sorting an intransitive total ordered set using semi-heap. In International Parallel and Distributed Processing Symposium, pages 257–262, 2000.
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 v1,…,vn • If v → v1, then v,v1,…,vn is a valid result • Otherwise let I be the largest index such that vi → v, then v1,…,vi,v,vi+1,…,vn or v1,…,vn,v respectively (i=n) is a valid result.