A Unified Approach To Parallel Depth-First Traversals of General Tree
A Unified Approach To Parallel Depth-First Traversals of General Tree
Calvin C.-Y. Chen, Sajal K. Das and Selim G. Akl Information Process Letters, vol. 38, pp.49-55, 1991
2002/2/28
depth-first traversal order
Definition.
1. Pre-order tree traversal 2. Post-order tree traversal
NEXT[ xi ] f k 1 c 1 if i no-of chil dren[x] 1 and node x is the kth child of its parent f , where x is not the root, if i no-of chil dren[x] 1 and c is the ith child of x.
Euler tour.
NEXT[c2]=f1;NEXT[f1]=c3;NEXT[c3]=g1;NEXT[g1]=c4;NEXT[c4]=a3;
NEXT[a3]=d1;NEXT[d1]=h1;NEXT[h1]=d2;NEXT[d2]=i1;NEXT[i1]=k1; NEXT[k1]=i2;NEXT[i2]=d3;NEXT[d3]=j1;NEXT[j1]=d4;NEXT[d4]=a4;
SUPERNODE: array[1..2n-1] of SNODEREC; for all Pi, 1 <= i <= n do parbegin Step_1 Processor Pi builds jth field of is parent node if node I is the jth child of its parent. The jth field (if it is not the last field) is stored in the ith index of array SUPERNODE. Step_2 Processor Pi builds node is last field whose array index is (n + i). parend.
SNODEREC:
Record
(X)node :integer;
1 2 3 4 5 6 7 8 9 1 1 1 1 1 1 1 1 1 1 2 2 2 0 1 2 3 4 5 6 7 8 9 0 1 2 X A A A C C C D D D I A B C D E F G H I J K
Y
Z
1 2 3 1 2 3 1 2 3 1 4 1 4 4 1 1 1 1 2 1 1
1 5 8 1 1 1 1 1 2 2 3 6 7 8 9 1 1 2 3 4 1 6 7 1 9 1 1 2 2 4 0 5 0
A binary tree:
Given the binary tree above, the linked list according to algorithm GEN-COMP-NEXT is: a1 b1 d1 b2 e1 g1 e2 b3 a2 c2 f1 c3 a3. Therefore, the in-order traversal of this binary tree is d b g e a c f.
1. The algorithm GEN-COMP-NEXT requires O( n / p ) time using p processors on the EREW model 2. It also requires O( n / p ) time to mark the nodes to be deleted (selected).
3. The linked list packing algorithm requires O( n / p + log n ) time on EREW model.
The time complexity of the preceding algorithms is thus proved.