Sorting an Intransitive Total Ordered Set - PowerPoint PPT Presentation

1 / 16
About This Presentation
Title:

Sorting an Intransitive Total Ordered Set

Description:

Recursively replace by winning child top-down. build-semi-heap (Q(n)) for i:=heapsize/2 downto 1 ... While updating the tree top-down, the work is handed from ... – PowerPoint PPT presentation

Number of Views:17
Avg rating:3.0/5.0
Slides: 17
Provided by: Joha186
Category:

less

Transcript and Presenter's Notes

Title: Sorting an Intransitive Total Ordered Set


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 PathA 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-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 iheapsize/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) 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

11
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 Brents Law.

12
Outlook
  • Extension
  • A Hamiltonian Cycle exists in every strong
    connected Tournament.
  • Definition of strong connectedEvery 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 http//www.jsingler.de/COMP5704/
  • References1 Danny Soroker. Fast parallel
    algorithms for finding Hamiltonian paths and
    cycles in a tournament. Journal of Algorithms,
    9(2)276286, June 1988.2 J. Wu. On sorting
    an intransitive total ordered set using
    semi-heap. In International Parallel and
    Distributed Processing Symposium, pages 257262,
    2000.

16
Appendix Proof of Theorem
  • By induction according to Soroker 1
  • Result clear for n2
  • n ? n1
  • 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,vi1,,vn or v1,,vn,v
    respectively (in) is a valid result.
Write a Comment
User Comments (0)
About PowerShow.com