580 likes | 740 Views
Sequential and Parallel Algorithms for Some Problems on Trees by Raymond Greenlaw Armstrong Atlantic State University. Joint work with:. R. Petreschi Department of Computer Science University of Rome La Sapienza. P. de la Torre Department of Computer Science University of New Hampshire.
E N D
Sequential and Parallel Algorithms for Some Problems on Trees by Raymond Greenlaw Armstrong Atlantic State University Joint work with: R. Petreschi Department of Computer ScienceUniversity of Rome La Sapienza P. de la TorreDepartment of Computer Science University of New Hampshire A. Schaffer National Institute of Health M. HalldorssonDecode Genetics T. Przytycka Department of Biophysics John Hopkins University Medical School Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw
Outline • Introduction • Parallel Preliminaries • Node Ranking • Edge Ranking • Prüfer Codes • Open Problems Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw
Outline • Introduction • Parallel Preliminaries • Node Ranking • Edge Ranking • Prüfer Codes • Open Problems Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw
Trees Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw
Outline • Introduction • Parallel Preliminaries • Node Ranking • Edge Ranking • Prüfer Codes • Open Problems Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw
P0 C0 P1 C1 P2 C2 Parallel Random Access Machine RAM Processors Global Memory Cells Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw
Preliminary Parallel Algorithms • Brent’s Scheduling Principle • Parallel Prefix Computation • Euler Tour • List Ranking • Parallel Tree Contraction Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw
Brent’s Scheduling Principle (Brent) If processor allocation is not a problem then a t(n) time parallel algorithm that requires w(n) computational operations can be simulated using w(n)/p(n) + t(n) time and p(n) processors. Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw
Example of Brent’s Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw
Parallel Prefix Computation (Ladner & Fisher) The Parallel Prefix Problem can be solved in O(log n) time using n/log n processors on an EREW-PRAM. Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw
Example of Parallel Prefix Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw
Euler Tour (Tarjan & Vishkin) An Euler tour of an n-node tree can be computed in O(log n) time using n/log n processors on an EREW-PRAM. Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw
Example of Euler Tour Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw
List Ranking (Anderson & Miller) Given a list with n nodes, the List Ranking Problem can be solved in O(log n) time using n/log n processors on an EREW-PRAM. Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw
Example of List Ranking Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw
Parallel Tree Contraction (He; Miller & Teng; Abrahamson, Dadoun, Kirkpatrick & Przytycka) Let T be an n-leaf regular binary expression tree. Then all of the algebraic expressions associated with the internal nodes (one per node) of T can be evaluated in O(log n) time using n/log n processors on an EREW-PRAM. Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw
Example of Tree Contraction Scrunched tree Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw
Outline • Introduction • Parallel Preliminaries • Node Ranking • Edge Ranking • Prüfer Codes • Open Problems Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw
Node Ranking • A node ranking is a labeling of the nodes of a tree with natural numbers such that if nodes u and v have the same label then there exists another node with a greater label on the path between them. • An optimal node ranking is a node ranking in which the largest label assigned to any node is as small as possible among all node rankings. • The node ranking problem is to compute an optimal node ranking. Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw
Node Ranking Example Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw
Node Ranking: Sequential Results • Node Ranking Problem • O(n log n) time (Iyer, Ratliff & Vijayan) • O(n) time (Schaffer) Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw
Example of Sequential Node Ranking Algorithm • Critical list at * is {3,4} • Label 3 at ** covers values 1 and 2 Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw
Example of Sequential Node Ranking Algorithm • Critical list at * is {3,4} • Label 3 at ** covers values 1 and 2 Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw
Node Ranking: Parallel Results • Approximate Optimal Tree Ranking • O(log2 n) time, n processors EREW-PRAM (Liang, Dhall & Lakshmivarahan) • Optimal Tree Ranking • O(log n) time, n2/log n procs CREW-PRAM (de la Torre & Greenlaw) (Przytycka) • Super Critical Tree Numbering O(log n) time, n2/log n procs CREW-PRAM (de la Torre, Greenlaw & Przytycka) Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw
Outline • Introduction • Parallel Preliminaries • Node Ranking • EdgeRanking • Prüfer Codes • Open Problems Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw
Edge Ranking • An edge ranking is a labeling of the edges of a tree with natural numbers such that if edges u and v have the same label then there exists another edge with a greater label on the path between them. • An optimal edge ranking is an edge ranking in which the largest label assigned to any edge is as small as possible among all edge rankings. • The edge ranking problem is to compute an optimal edge ranking. Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw
Edge Ranking Example Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw
Edge Ranking: Sequential Results • Approximate Edge Ranking • O(n log n) time (Iyer, Ratliff & Vijayan) • Optimal Edge Ranking • O(n3 log n) time (de la Torre, Greenlaw & Schaffer) • O(n2 log n) time (Zhou, Kashem & Nishizeki) • O(n log n) time, O(n) time (Lam & Ling) Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw
From Local to Global Optimality Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw
Greedy Cover Labeling • Lc > Lc-1 > … > L1 is a greedy cover labeling if and only if cover(Li, crit(vj)) lex cover(Li, crit(vi)) for all i and for all j < i. Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw
Example of Edge Ranking Algorithm Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw
Example of Edge Ranking Algorithm Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw
Example of Edge Ranking Algorithm Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw
Edge Ranking: Parallel Results • Approximate Edge Ranking • O(log2 n) time, n2/log n processors CREW-PRAM (de la Torre, Greenlaw & Schaffer) • Optimal Edge Ranking of Constant Degree Trees NC (de la Torre, Greenlaw & Schaffer) Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw
Motivation for Studying Rankings Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw
Motivation for Studying Rankings Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw
Outline • Introduction • Parallel Preliminaries • Node Ranking • Edge Ranking • PrüferCodes • Open Problems Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw
Definition of Prüfer Code A Prüfer code of a labeled free tree with n nodes is a sequence of length n – 2 constructed by the following sequential process: for i ranging from 1 to n – 2 do insert the label of the neighbor of the smallest remaining leaf into the i-th position of the sequence; delete the leaf; Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw
Example of a Prüfer Code (9,6,5,6,1,6,1,1) Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw
Related Work • Prüfer code to tree EREW-PRAM O(log n) time, n processors proposed as an open problem the reverse direction (Wang, Chen & Liu) • Tree to Prüfer code EREW-PRAM O(log n) time, n processors (Chen & Wang, Greenlaw & Petreschi) Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw
Related Work Continued • Chain to Prüfer code EREW-PRAM O(log n) time, n/log n (Greenlaw & Petreschi) • Used Prüfer codes for random tree generation (Kumar, Deo & Kumar) Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw
Can Sequential AlgorithmPrüfer Code Be Parallelized? • Initial intuition suggests no. • What type of running time do we want? • How do we proceed? Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw
Parallel Algorithm Prüfer Chain The Prüfer code of this chain is (2,8,3,7,5,6) Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw
Parallel Algorithm Prüfer ChainStep 1: /* Compute the position of each node in the chain. */ • Use parallel list ranking to construct the array Position such that Position[i] = v, 1 i n, where node v has a ranking of i in T Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw
Parallel Algorithm Prüfer ChainStep 2: /* Compute the maximum nodes encountered thus far in left-to-right and right-to-left traversals over the chain. */ 2. Use parallel prefix computation to construct the arrays LRMax and RLMax LRMax[i] = max{Position[j] | 1 j i} RLMax[i] = max{Position[j] | n – i + 1 j n} Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw
Parallel Algorithm Prüfer ChainStep 3: /* Compute when a node becomes a maximum (if it does) for both left-to-right and right-to-left traversals. */ 3. For 1 i n in parallel do if LRMax[i-1] LRMax[i] then LRStart[LRMax[i]] = i; if RLMax[i-1] RLMax[i] then RLStart[RLMax[i]] = i; Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw
Parallel Algorithm Prüfer ChainStep 4: /* Compute when a node is no longer a maximum (if it was) for both left-to-right and right-to-left traversals. */ 4. For 1 i n in parallel do if LRMax[i] LRMax[i+1] then LREnd[LRMax[i]] = i; if RLMax[i] RLMax[i+1] then RLEnd[RLMax[i]] = i; Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw
Parallel Algorithm Prüfer ChainStep 5: /* Compute how many positions a node was maximum for. */ 5. For 1 i n in parallel do if LRStart[i] 0 then LRSpan[i] = LREnd[i] - LRStart[i] + 1; if RLStart[i] 0 then RLSpan[i] = RLEnd[i] - RLStart[i] + 1; Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw
Parallel Algorithm Prüfer ChainStep 6: /* Compute how many nodes a given node is greater than from the left. Similiarly for the right. */ • Use parallel prefix to construct the array LeftClear and RightClear, where 1 i n LeftClear[i] = LRSpan[0] + … + LRSpan[i-1]; RightClear[i] = RLSpan[0] + … + RLSpan[i-1]; Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw
Parallel Algorithm Prüfer ChainStep 7: /* Removal[i] denotes when the node in Position[i] is removed. */ 7. For 1 i n in parallel do if RLMax[n-i] > LRMax[i-1] then k = LRMax[i]; Removal[i] = i + RightClear[k]; else k = RLMax[n-i+1]; Removal[i] = (n – i) + 1 + LeftClear[k]; Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw