Advanced Topics in Algorithms and Data Structures

Slides:



Advertisements
Similar presentations
Chapter 10, Section 10.3 Tree Traversal
Advertisements

Mathematical Preliminaries
Introduction to Algorithms 6.046J/18.401J/SMA5503
0 - 0.
CS16: Introduction to Data Structures & Algorithms
Graph Algorithms Algorithm Design and Analysis Victor AdamchikCS Spring 2014 Lecture 11Feb 07, 2014Carnegie Mellon University.
Parallel List Ranking Advanced Algorithms & Data Structures Lecture Theme 17 Prof. Dr. Th. Ottmann Summer Semester 2006.
CS 336 March 19, 2012 Tandy Warnow.
1 Directed Depth First Search Adjacency Lists A: F G B: A H C: A D D: C F E: C D G F: E: G: : H: B: I: H: F A B C G D E H I.
Great Theoretical Ideas in Computer Science for Some.
Addition 1’s to 20.
Test B, 100 Subtraction Facts
Chapter 12 Binary Search Trees
CS203 Lecture 15.
Introduction to Algorithms Lecture 12 Prof. Constantinos Daskalakis CLRS
Trees Chapter 11.
Bart Jansen 1.  Problem definition  Instance: Connected graph G, positive integer k  Question: Is there a spanning tree for G with at least k leaves?
Epp, section 10.? CS 202 Aaron Bloomfield
 Theorem 5.9: Let G be a simple graph with n vertices, where n>2. G has a Hamilton circuit if for any two vertices u and v of G that are not adjacent,
Introduction to Graph Theory Instructor: Dr. Chaudhary Department of Computer Science Millersville University Reading Assignment Chapter 1.
Chapter 10: Trees. Definition A tree is a connected undirected acyclic (with no cycle) simple graph A collection of trees is called forest.
Introduction to Graphs
©Brooks/Cole, 2003 Chapter 12 Abstract Data Type.
Advanced Topics in Algorithms and Data Structures Lecture pg 1 Recursion.
Data Structures, Spring 2004 © L. Joskowicz 1 Data Structures – LECTURE 14 Strongly connected components Definition and motivation Algorithm Chapter 22.5.
Advanced Topics in Algorithms and Data Structures 1 Rooting a tree For doing any tree computation, we need to know the parent p ( v ) for each node v.
Parallel Prefix Computation Advanced Algorithms & Data Structures Lecture Theme 14 Prof. Dr. Th. Ottmann Summer Semester 2006.
What is the first line of the proof? a). Assume G has an Eulerian circuit. b). Assume every vertex has even degree. c). Let v be any vertex in G. d). Let.
Binary Tree Terminology Linear versus hierarchical data Tree – connected graph with no cycles Child Parent Descendant Sibling Ancestor Leaf vs. internal.
Advanced Topics in Algorithms and Data Structures 1 Lecture 4 : Accelerated Cascading and Parallel List Ranking We will first discuss a technique called.
Topics: 1. Trees - properties 2. The master theorem 3. Decoders מבנה המחשב - אביב 2004 תרגול 4#
Advanced Topics in Algorithms and Data Structures Page 1 An overview of lecture 3 A simple parallel algorithm for computing parallel prefix. A parallel.
The Euler-tour technique
Data Structures, Spring 2006 © L. Joskowicz 1 Data Structures – LECTURE 14 Strongly connected components Definition and motivation Algorithm Chapter 22.5.
2/10/03Tucker, Sec Tucker, Applied Combinatorics, Sec. 3.2, Important Definitions Enumeration: Finding all of the possible paths in a rooted tree.
Advanced Topics in Algorithms and Data Structures 1 Two parallel list ranking algorithms An O (log n ) time and O ( n log n ) work list ranking algorithm.
C o n f i d e n t i a l HOME NEXT Subject Name: Data Structure Using C Unit Title: Trees.
Advanced Topics in Algorithms and Data Structures 1 An example.
Trees and Tree Traversals Prof. Sin-Min Lee Department of Computer Science San Jose State University.
Theory of Computing Lecture 10 MAS 714 Hartmut Klauck.
ساختمانهای گسسته دانشگاه صنعتی شاهرود – اردیبهشت 1392.
“On an Algorithm of Zemlyachenko for Subtree Isomorphism” Yefim Dinitz, Alon Itai, Michael Rodeh (1998) Presented by: Masha Igra, Merav Bukra.
Foundations of Discrete Mathematics
CSCI 115 Chapter 7 Trees. CSCI 115 §7.1 Trees §7.1 – Trees TREE –Let T be a relation on a set A. T is a tree if there exists a vertex v 0 in A s.t. there.
5.5.2 M inimum spanning trees  Definition 24: A minimum spanning tree in a connected weighted graph is a spanning tree that has the smallest possible.
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.
Discrete Structures Trees (Ch. 11)
CSE 589 Part VI. Reading Skiena, Sections 5.5 and 6.8 CLR, chapter 37.
5.5.2 M inimum spanning trees  Definition 24: A minimum spanning tree in a connected weighted graph is a spanning tree that has the smallest possible.
Trees : Part 1 Section 4.1 (1) Theory and Terminology (2) Preorder, Postorder and Levelorder Traversals.
Data Structures and Algorithms in Parallel Computing Lecture 2.
Trees 2: Section 4.2 and 4.3 Binary trees. Binary Trees Definition: A binary tree is a rooted tree in which no vertex has more than two children
Trees By P.Naga Srinivasu M.tech,(MBA). Basic Tree Concepts A tree consists of finite set of elements, called nodes, and a finite set of directed lines.
Fall 2008Simple Parallel Algorithms1. Fall 2008Simple Parallel Algorithms2 Scalar Product of Two Vectors Let a = (a 1, a 2, …, a n ); b = (b 1, b 2, …,
3/12/2013Computer Engg, IIT(BHU)1 PRAM ALGORITHMS-3.
COMPSCI 102 Introduction to Discrete Mathematics.
1 Trees : Part 1 Reading: Section 4.1 Theory and Terminology Preorder, Postorder and Levelorder Traversals.
Chapter 11. Chapter Summary Introduction to Trees Applications of Trees (not currently included in overheads) Tree Traversal Spanning Trees Minimum Spanning.
Theory of Computational Complexity Probability and Computing Chapter Hikaru Inada Iwama and Ito lab M1.
Chapter 5 : Trees.
MCS680: Foundations Of Computer Science
Trees Chapter 11.
Source Code for Data Structures and Algorithm Analysis in C (Second Edition) – by Weiss
Section 8.1 Trees.
CS223 Advanced Data Structures and Algorithms
CSE 421: Introduction to Algorithms
Graphs Chapter 11 Objectives Upon completion you will be able to:
Section 9.3 by Andrew Watkins
Chapter 20: Binary Trees.
Trees Chapter 11.
Presentation transcript:

Advanced Topics in Algorithms and Data Structures An overview of lecture 5 The Euler tour technique Computation of different tree functions Tree contraction Evaluation of arithmetic expressions Advanced Topics in Algorithms and Data Structures

Problems in parallel computations of tree functions Computations of tree functions are important for designing many algorithms for trees and graphs. Some of these computations include preorder, postorder, inorder numbering of the nodes of a tree, number of descendants of each vertex, level of each vertex etc. Advanced Topics in Algorithms and Data Structures

Problems in parallel computations of tree functions Most sequential algorithms for these problems use depth-first search for solving these problems. However, depth-first search seems to be inherently sequential in some sense. Advanced Topics in Algorithms and Data Structures

Parallel depth-first search It is difficult to do depth-first search in parallel. We cannot assign depth-first numbering to the node n unless we have assigned depth-first numbering to all the nodes in the subtree A. Advanced Topics in Algorithms and Data Structures

Parallel depth-first search There is a definite order of visiting the nodes in depth-first search. We can introduce additional edges to the tree to get this order. The Euler tour technique converts a tree into a list by adding additional edges. Advanced Topics in Algorithms and Data Structures

Parallel depth-first search The red (or, magenta ) arrows are followed when we visit a node for the first (or, second) time. If the tree has n nodes, we can construct a list with 2n - 2 nodes, where each arrow (directed edge) is a node of the list. Advanced Topics in Algorithms and Data Structures

Advanced Topics in Algorithms and Data Structures Euler tour technique For a node v T, p(v) is the parent of v. Each red node in the list represents an edge of the nature < p(v) , v >. We can determine the preorder numbering of a node of the tree by counting the red nodes in the list. Advanced Topics in Algorithms and Data Structures

Advanced Topics in Algorithms and Data Structures Euler tour technique Let T = (V, E) be a given tree and let T’ = (V, E’ ) be a directed graph obtained from T. Each edge (u, v)  E is replaced by two edges < u, v > and < v, u >. Both the indegree and outdegree of an internal node of the tree are now same. The indegree and outdegree of a leaf is 1 each. Hence T’ is an Eulerian graph. Advanced Topics in Algorithms and Data Structures

Advanced Topics in Algorithms and Data Structures Euler tour technique An Euler circuit of a graph is an edge-disjoint circuit which traverses all the nodes. A graph permits an Euler circuit if and only if each vertex has equal indegree and outdegree. An Euler circuit can be used for optimal parallel computation of many tree functions. To construct an Euler circuit, we have to specify the successor edge for each edge. Advanced Topics in Algorithms and Data Structures

Constructing an Euler tour Each edge on an Euler circuit has a unique successor edge. For each vertex v V we fix an ordering of the vertices adjacent to v. If d is the degree of vertex v, the vertices adjacent to v are: adj(v) = < u0, u1, …, ud -1 > The successor of edge < ui, v > is: s(< ui, v >) = < v, u(i + 1) mod d >, 0  i  (d - 1) Advanced Topics in Algorithms and Data Structures

Constructing an Euler tour Advanced Topics in Algorithms and Data Structures

Correctness of Euler tour Consider the graph T’ = (V, E’ ) , where E’ is obtained by replacing each e E by two directed edges of opposite directions. Lemma: The successor function s defines only one cycle and not a set of edge-disjoint cycles in T’. Proof: We have already shown that the graph is Eulerian. We prove the lemma through induction. Advanced Topics in Algorithms and Data Structures

Correctness of Euler tour basis: When the tree has 2 nodes, there is only one edge and one cycle with two edges. Suppose, the claim is true for n nodes. We should show that it is true when there are n + 1 nodes. Advanced Topics in Algorithms and Data Structures

Correctness of Euler tour We can introduce an extra node by introducing a leaf to an existing tree, like the leaf v. Initially, adj(u) = <…, v’, v’’, …> . Hence, s(< v’, u >) = < u, v’’ >. Advanced Topics in Algorithms and Data Structures

Correctness of Euler tour After the introduction of v, adj(u) = <…, v’, v, v’’, …> s(< v’, u >) = < u, v > and s(< v, u >) = < u, v’’ > Hence, there is only one cycle after v is introduced. Advanced Topics in Algorithms and Data Structures

Construction of Euler tour in parallel Advanced Topics in Algorithms and Data Structures

Construction of Euler tour in parallel We assume that the tree is given as a set of adjacency lists for the nodes. The adjacency list L[v] for v is given in an array. Consider a node v and a node ui adjacent to v. We need: The successor < v, u(i + 1) mod d > for < ui, v >. This is done by making the list circular. < ui, v >. This is done by keeping a direct pointer from ui in L[v] to v in L[ui]. Advanced Topics in Algorithms and Data Structures

Construction of Euler tour in parallel We can construct an Euler tour in O(1) time using O(n) processors. One processor is assigned to each node of the adjacency list. There is no need of concurrent reading, hence the EREW PRAM model is sufficient. Advanced Topics in Algorithms and Data Structures