sequential and parallel algorithms for some problems on trees raymond greenlaw 1 sequential and...

58
Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond Greenlaw Armstrong Atlantic State University Joint work with: P. de la Torre Department of Computer Science University of New Hampshire M. Halldorsson Decode Genetics T. Przytycka Department of Biophysics John Hopkins University Medical School A. Schaffer National Institute of Health R. Petreschi Department of Computer Science University of Rome La Sapienza

Upload: julia-donnelly

Post on 27-Mar-2015

234 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

1

Sequential and Parallel Algorithms for Some Problems on Trees

by

Raymond GreenlawArmstrong Atlantic State University

Sequential and Parallel Algorithms for Some Problems on Trees

by

Raymond GreenlawArmstrong Atlantic State University

Joint work with:P. de la Torre

Department of Computer ScienceUniversity of New Hampshire

M. Halldorsson Decode Genetics

T. Przytycka Department of Biophysics

John Hopkins University Medical School

A. SchafferNational Institute of Health

R. Petreschi Department of Computer ScienceUniversity of Rome La Sapienza

Page 2: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

2

OutlineOutline

• Introduction• Parallel Preliminaries• Node Ranking• Edge Ranking• Prüfer Codes• Open Problems

Page 3: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

3

OutlineOutline

• Introduction• Parallel Preliminaries• Node Ranking• Edge Ranking• Prüfer Codes• Open Problems

Page 4: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

4

TreesTrees

Page 5: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

5

OutlineOutline

• Introduction• Parallel Preliminaries• Node Ranking• Edge Ranking• Prüfer Codes• Open Problems

Page 6: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

6

Parallel Random Access MachineParallel Random Access Machine

RAM Processors

Global Memory Cells

P0 P1 P2

C0 C1 C2

Page 7: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

7

Preliminary Parallel AlgorithmsPreliminary Parallel Algorithms

• Brent’s Scheduling Principle• Parallel Prefix Computation• Euler Tour• List Ranking• Parallel Tree Contraction

Page 8: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

8

Brent’s Scheduling PrincipleBrent’s Scheduling Principle

(Brent) If processor allocation is not a problemthen a t(n) time parallel algorithm that requires w(n) computational operations

canbe simulated using w(n)/p(n) + t(n) time

andp(n) processors.

Page 9: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

9

Example of Brent’sExample of Brent’s

Page 10: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

10

Parallel Prefix ComputationParallel Prefix Computation

(Ladner & Fisher)The Parallel Prefix Problem can besolved in O(log n) time using n/log nprocessors on an EREW-PRAM.

Page 11: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

11

Example of Parallel PrefixExample of Parallel Prefix

Page 12: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

12

Euler Tour Euler Tour

(Tarjan & Vishkin)An Euler tour of an n-node tree can becomputed in O(log n) time using n/log nprocessors on an EREW-PRAM.

Page 13: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

13

Example of Euler TourExample of Euler Tour

Page 14: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

14

List RankingList 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.

Page 15: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

15

Example of List RankingExample of List Ranking

Page 16: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

16

Parallel Tree ContractionParallel Tree Contraction

(He; Miller & Teng; Abrahamson, Dadoun, Kirkpatrick & Przytycka)

Let T be an n-leaf regular binary expressiontree. Then all of the algebraic expressionsassociated with the internal nodes (one pernode) of T can be evaluated in O(log n) time using n/log n processors on an EREW-PRAM.

Page 17: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

17

Example of Tree ContractionExample of Tree Contraction

Scrunched tree

Page 18: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

18

OutlineOutline

• Introduction• Parallel Preliminaries• Node Ranking• Edge Ranking• Prüfer Codes• Open Problems

Page 19: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

19

Node RankingNode 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.

Page 20: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

20

Node Ranking ExampleNode Ranking Example

Page 21: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

21

Node Ranking: Sequential ResultsNode Ranking: Sequential Results

• Node Ranking Problem• O(n log n) time (Iyer, Ratliff & Vijayan)• O(n) time (Schaffer)

Page 22: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

22

Example of Sequential Node Ranking Algorithm

Example of Sequential Node Ranking Algorithm

• Critical list at * is {3,4}• Label 3 at ** covers values 1 and 2

Page 23: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

23

Example of Sequential Node Ranking Algorithm

Example of Sequential Node Ranking Algorithm

• Critical list at * is {3,4}• Label 3 at ** covers values 1 and 2

Page 24: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

24

Node Ranking: Parallel ResultsNode 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)

Page 25: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

25

OutlineOutline

• Introduction• Parallel Preliminaries• Node Ranking• Edge Ranking• Prüfer Codes• Open Problems

Page 26: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

26

Edge RankingEdge 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.

Page 27: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

27

Edge Ranking ExampleEdge Ranking Example

Page 28: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

28

Edge Ranking: Sequential ResultsEdge 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)

Page 29: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

29

From Local to Global OptimalityFrom Local to Global Optimality

Page 30: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

30

Greedy Cover LabelingGreedy 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.

Page 31: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

31

Example of Edge Ranking AlgorithmExample of Edge Ranking Algorithm

Page 32: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

32

Example of Edge Ranking AlgorithmExample of Edge Ranking Algorithm

Page 33: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

33

Example of Edge Ranking AlgorithmExample of Edge Ranking Algorithm

Page 34: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

34

Edge Ranking: Parallel ResultsEdge 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)

Page 35: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

35

Motivation for Studying RankingsMotivation for Studying Rankings

Page 36: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

36

Motivation for Studying RankingsMotivation for Studying Rankings

Page 37: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

37

OutlineOutline

• Introduction• Parallel Preliminaries• Node Ranking• Edge Ranking• Prüfer Codes• Open Problems

Page 38: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

38

Definition of Prüfer CodeDefinition 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;

Page 39: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

39

Example of a Prüfer CodeExample of a Prüfer Code

(9,6,5,6,1,6,1,1)

Page 40: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

40

Related WorkRelated 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)

Page 41: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

41

Related Work ContinuedRelated 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)

Page 42: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

42

Can Sequential AlgorithmPrüfer Code Be Parallelized?Can Sequential Algorithm

Prüfer Code Be Parallelized?

• Initial intuition suggests no.• What type of running time do we want?• How do we proceed?

Page 43: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

43

Parallel Algorithm Prüfer ChainParallel Algorithm Prüfer Chain

The Prüfer code of this chain is(2,8,3,7,5,6)

Page 44: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

44

Parallel Algorithm Prüfer ChainStep 1:

Parallel Algorithm Prüfer ChainStep 1:

/* Compute the position of each node in the chain. */1. 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

12865734

87654321

Page 45: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

45

Parallel Algorithm Prüfer ChainStep 2:

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}

0 4 4 7 7 7 8 8 8 9

0 1 2 8 8 8 8 8 8 9

Page 46: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

46

Parallel Algorithm Prüfer ChainStep 3:

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;

0 0 0 1 0 0 3 6

1 2 0 0 0 0 0 3

Page 47: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

47

Parallel Algorithm Prüfer ChainStep 4:

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;

0 0 0 2 0 0 5 8

1 2 0 0 0 0 0 8

Page 48: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

48

Parallel Algorithm Prüfer ChainStep 5:

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;

0 0 0 0 2 0 0 3 3

0 1 1 0 0 0 0 0 6

Page 49: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

49

Parallel Algorithm Prüfer ChainStep 6:

Parallel Algorithm Prüfer ChainStep 6:

/* Compute how many nodes a given node is greater than from the left. Similiarly for the right. */

6. 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];

0 0 0 0 2 2 2 5

0 1 2 2 2 2 2 2

Page 50: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

50

Parallel Algorithm Prüfer ChainStep 7:

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];

3 4 5 6 7 8 2 1

Page 51: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

51

Theorem on ChainsTheorem on Chains

(Greenlaw & Petreschi)

The Prüfer code of an n-node labeled chain can be computed in O(log n) time using n/log n processors on an

EREW-PRAM.

Page 52: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

52

Parallel Algorithm Prüfer TreeParallel Algorithm Prüfer Tree

Page 53: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

53

Parallel Algorithm Prüfer TreeParallel Algorithm Prüfer Tree

Page 54: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

54

Theorem on TreesTheorem on Trees

(Greenlaw, Halldorsson & Petreschi) The Prüfer code of an n-node labeled free tree can be computed in O(log n)

time using n/log n processors on an EREW-PRAM. In the other direction we show Given the Prüfer code of an n-node

labeled chain we can output the corresponding chain in O(log n) time using n/log n processors on an EREW-PRAM.

Page 55: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

55

Prüfer Code SummaryPrüfer Code Summary

Tree to P-code P-code to Tree

sequential

O(n) folklore O(n)

parallel O(log n) time, n processorsEREW-PRAM

O(log n) time, n processorsEREW-PRAM

For a chain O(log n) time,n/log n processors EREW-PRAM

For a chainO(log n) time, n/log n processorsEREW-PRAM

For a treeO(log n) time, n/log n processorsEREW-PRAM

Page 56: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

56

OutlineOutline

• Introduction• Parallel Preliminaries• Node Ranking• Edge Ranking• Prüfer Codes• Open Problems

Page 57: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

57

Open ProblemsOpen Problems

• Can an optimal parallel algorithm be developed for building a tree given its Prüfer code?

• Can the Element Distinctness Problem be solved on a CREW-PRAM in O(log n) time using n/log n processors?

• Is the edge ranking problem on trees P-complete?• Can all n-node trees be labeled with the

values 1 through n such that neighors receive pairwise relatively prime labels?

Page 58: Sequential and Parallel Algorithms for Some Problems on Trees Raymond Greenlaw 1 Sequential and Parallel Algorithms for Some Problems on Trees by Raymond

Sequential and Parallel Algorithms for Some Problems on TreesRaymond Greenlaw

58

ReferencesReferences

See www.cs.armstrong.edu/greenlaw