Sorting an Intransitive Total Ordered Set

Slides:



Advertisements
Similar presentations
Parallel Algorithms.
Advertisements

CS 336 March 19, 2012 Tandy Warnow.
Introduction to Computer Science 2 Lecture 7: Extended binary trees
Divide and Conquer. Subject Series-Parallel Digraphs Planarity testing.
Midwestern State University Department of Computer Science Dr. Ranette Halverson CMPS 2433 – CHAPTER 4 GRAPHS 1.
§6 Leftist Heaps CHAPTER 5 Graph Algorithms  Heap: Structure Property + Order Property Target : Speed up merging in O(N). Leftist Heap: Order Property.
Heaps1 Part-D2 Heaps Heaps2 Recall Priority Queue ADT (§ 7.1.3) A priority queue stores a collection of entries Each entry is a pair (key, value)
Lecture 3: Parallel Algorithm Design
AVL Trees1 Part-F2 AVL Trees v z. AVL Trees2 AVL Tree Definition (§ 9.2) AVL trees are balanced. An AVL Tree is a binary search tree such that.
Greedy Algorithms Greed is good. (Some of the time)
CMPS 2433 Discrete Structures Chapter 5 - Trees R. HALVERSON – MIDWESTERN STATE UNIVERSITY.
Lectures on Network Flows
Advanced Topics in Algorithms and Data Structures Lecture pg 1 Recursion.
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 21: Graphs.
Parallel Architectures: Topologies Heiko Schröder, 2003.
Parallel Prefix Computation Advanced Algorithms & Data Structures Lecture Theme 14 Prof. Dr. Th. Ottmann Summer Semester 2006.
More sorting algorithms: Heap sort & Radix sort. Heap Data Structure and Heap Sort (Chapter 7.6)
Heapsort. 2 Why study Heapsort? It is a well-known, traditional sorting algorithm you will be expected to know Heapsort is always O(n log n) Quicksort.
TCSS 342 AVL Trees v1.01 AVL Trees Motivation: we want to guarantee O(log n) running time on the find/insert/remove operations. Idea: keep the tree balanced.
CS 206 Introduction to Computer Science II 10 / 31 / 2008 Happy Halloween!!! Instructor: Michael Eckmann.
Lists A list is a finite, ordered sequence of data items. Two Implementations –Arrays –Linked Lists.
CS 206 Introduction to Computer Science II 11 / 03 / 2008 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 03 / 25 / 2009 Instructor: Michael Eckmann.
Costas Busch - RPI1 Mathematical Preliminaries. Costas Busch - RPI2 Mathematical Preliminaries Sets Functions Relations Graphs Proof Techniques.
CS 206 Introduction to Computer Science II 11 / 09 / 2009 Instructor: Michael Eckmann.
Advanced Topics in Algorithms and Data Structures Page 1 An overview of lecture 3 A simple parallel algorithm for computing parallel prefix. A parallel.
Courtesy Costas Busch - RPI1 Mathematical Preliminaries.
The Euler-tour technique
Simulating a CRCW algorithm with an EREW algorithm Lecture 4 Efficient Parallel Algorithms COMP308.
Advanced Data Structures and Algorithms COSC-600 Lecture presentation-6.
Heapsort Based off slides by: David Matuszek
CS Data Structures Chapter 5 Trees. Chapter 5 Trees: Outline  Introduction  Representation Of Trees  Binary Trees  Binary Tree Traversals 
“On an Algorithm of Zemlyachenko for Subtree Isomorphism” Yefim Dinitz, Alon Itai, Michael Rodeh (1998) Presented by: Masha Igra, Merav Bukra.
Heapsort CSC Why study Heapsort? It is a well-known, traditional sorting algorithm you will be expected to know Heapsort is always O(n log n)
1 Trees A tree is a data structure used to represent different kinds of data and help solve a number of algorithmic problems Game trees (i.e., chess ),
1 Greedy algorithm 叶德仕 2 Greedy algorithm’s paradigm Algorithm is greedy if it builds up a solution in small steps it chooses a decision.
Data Structure & Algorithm II.  Delete-min  Building a heap in O(n) time  Heap Sort.
Mathematical Preliminaries. Sets Functions Relations Graphs Proof Techniques.
Complexity 20-1 Complexity Andrei Bulatov Parallel Arithmetic.
Fall 2005Costas Busch - RPI1 Mathematical Preliminaries.
Prof. Busch - LSU1 Mathematical Preliminaries. Prof. Busch - LSU2 Mathematical Preliminaries Sets Functions Relations Graphs Proof Techniques.
 Rooted tree and binary tree  Theorem 5.19: A full binary tree with t leaves contains i=t-1 internal vertices.
5.5.3 Rooted tree and binary tree  Definition 25: A directed graph is a directed tree if the graph is a tree in the underlying undirected graph.  Definition.
Prepared by- Jatinder Paul, Shraddha Rumade
Lectures on Greedy Algorithms and Dynamic Programming
Chapter 2: Basic Data Structures. Spring 2003CS 3152 Basic Data Structures Stacks Queues Vectors, Linked Lists Trees (Including Balanced Trees) Priority.
Trees : Part 1 Section 4.1 (1) Theory and Terminology (2) Preorder, Postorder and Levelorder Traversals.
CPSC 252 Binary Heaps Page 1 Binary Heaps A complete binary tree is a binary tree that satisfies the following properties: - every level, except possibly.
Heapsort. What is a “heap”? Definitions of heap: 1.A large area of memory from which the programmer can allocate blocks as needed, and deallocate them.
Lecture 15 Jianjun Hu Department of Computer Science and Engineering University of South Carolina CSCE350 Algorithms and Data Structure.
Lecture 8 : Priority Queue Bong-Soo Sohn Assistant Professor School of Computer Science and Engineering Chung-Ang University.
CMSC 341 Introduction to Trees. 2/21/20062 Tree ADT Tree definition –A tree is a set of nodes which may be empty –If not empty, then there is a distinguished.
1 Mathematical Preliminaries. 2 Sets Functions Relations Graphs Proof Techniques.
Heaps © 2010 Goodrich, Tamassia. Heaps2 Priority Queue ADT  A priority queue (PQ) stores a collection of entries  Typically, an entry is a.
3/12/2013Computer Engg, IIT(BHU)1 PRAM ALGORITHMS-3.
1 Trees : Part 1 Reading: Section 4.1 Theory and Terminology Preorder, Postorder and Levelorder Traversals.
5.6 Prefix codes and optimal tree Definition 31: Codes with this property which the bit string for a letter never occurs as the first part of the bit string.
De Bruijn sequences 陳柏澍 Novembers Each of the segments is one of two types, denoted by 0 and 1. Any four consecutive segments uniquely determine.
Lecture 3: Parallel Algorithm Design
Source Code for Data Structures and Algorithm Analysis in C (Second Edition) – by Weiss
Heaps © 2010 Goodrich, Tamassia Heaps Heaps
Heap Sort Example Qamar Abbas.
Lectures on Network Flows
Trees 1: Theory, Models, Generic Heap Algorithms, Priority Queues
Heapsort.
Mathematical Preliminaries
Heapsort Sorting in place
Heapsort.
Heapsort.
CO 303 Algorithm Analysis and Design
Presentation transcript:

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-sort build-semi-heap While 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.