ELSEVIER Information Processing Letters 54 (1995) 69-72
Information
Processing
Letters
Compact embedding of binary trees into hypercubes
Chui-Cheng Chen, Rong-Jaye Chen
*Department of Computer Science and Information Engineering National Chiao Tung University, 1001 TA Hsueh Road, Hsinchu 30050, Taiwan, ROC
Communicated by R.S. Bird; received 19 October 1994; revised 24 January 1995
Keywords: Embedding; Binary tree; Hypercube
1. Introduction
Over the years, many authors have discussed the embedding of binary trees in hypercubes [2-71.
They studied the one-to-one node embedding of
binary trees into hypercubes. Wu [71 has shown that a complete binary tree of height h (h 2 O), which has 2h+’ - 1 nodes, can be embedded into an (h + 2)dimensional hypercube and that the adjacency of the complete binary tree is pre- served. In [2,4], it has been proved that a double- rooted complete binary tree of height h is a subgraph of an (h + l&dimensional hypercube. Tzeng et al. [5] have shown that a complete binary tree of height h can be embedded into an incomplete hypercube which comprises an (h +
l)-dimensional hypercube and an h-dimensional hypercube, and that an incomplete binary tree with 2h-1 +2h-2 - 1 nodes can be embedded into an h-dimensional hypercube. Wagner [6] de- scribed the embedding of a binary tree of height
h into an h-dimensional hypercube, which was complete for the first h - 2 levels.
incomplete hypercube of the smallest size and to look in a hypercube for an incomplete binary tree that is larger than the incomplete binary tree in [S]. In Section 2, we describe some preliminaries for embedding. In Section 3, we prove that the complete binary tree can be embedded into an incomplete hypercube, then prove that the size of the incomplete hypercubes is the smallest. In Section 4, we look for an incomplete binary tree in a hypercube.
2. Preliminaries
A complete binary tree of height h, Th, is a rooted binary tree. The root of the complete binary tree is in level 0, two nodes in level 1, four nodes in level 2, 2’ nodes in level i, etc., and the total number of any complete binary tree of height
h is 2h+’ - 1. A double-rooted complete binary
tree is a complete binary tree with the root re- placed by a path of length two [2].
The objective of this paper is to show how to embed a complete binary tree of height h into an
* Corresponding author.
We denote the n-dimensional hypercube with 2” nodes as H,. These nodes of H, are labeled {O, I, * f ., 2” - l} as binary number. Two nodes in the hypercube are linked with an edge if and only if their binary numbers differ by a single bit. The
Hamming distance is the number of different bits 0020-0190/95/$09.50 0 1995 Elsevier Science B.V. All rights reserved
70 C.-C. Chen, R.-J. Chen /Information Processing Letters 54 (199.5) 69-72
T2 7-3
Fig. 1. Coloring of T2 and T3.
between two nodes. If a hypercube misses some certain nodes, it is called an incomplete hyper- cube [ll. Let ZH(n,, n2,. . ., ni> denote the in- complete hypercube comprising i complete hy- percubes: H,], H,,l,. . . , H,,j,. . . , Hni, nj > ni > 0,
which can be obtained by deleting the largest 2”1 - (29 + . . . +2”j) nodes (in binary number) and their neighboring edges from an (n, + I)- dimensional hypercube.
To conveniently describe the embedding, we use two colors, black and white, to correspond to the binary number of each node. If the binary number contains an even number of l’s, we color the node black. Otherwise, we color the node white. Since the hypercube has a perfect match- ing, the n-dimensional hypercube has 2”-’ black nodes (with an even number of l’s) and 2”-’ white nodes (with an odd number of l’s). If Th is embedded into a hypercube, the nodes of two consecutive levels of Th have to be mapped to the nodes with different colors in the hypercube. The nodes with the same color as the leaf nodes are more than the nodes with the other color. Without loss of generality, we color the leaf nodes black, their parents white, and so the root black if the height h is even, white if h is odd (see Fig. 1 for coloring of T2 and T3).
3. Embedding complete binary trees into incom-
plete hypercubes
In this section we show how to embed a com- plete binary tree into an incomplete hypercube of the smallest, size. For the embedding, we need the following lemmas.
Lemma 1. 7Yhe total number of black nodes on the tree Th is (2h+2- 2)/3 if h is odd, and (2hi2 - 1)/3 if h is even [3,6,7].
root
l2r
(a) (b)
Fig. 2. (a) T2 is embedded into IH(3,O). (b) T3 is embedded into IH(4,1,0). (All the embedded tree nodes are linked by solid lines in the incomplete hypercube.)
Lemma 2. A double-rooted complete binary tree of height h can be embedded into an (h + l)-
dimensional hypercube [2,4].
Now we show that an incomplete hypercube of a specified size can be embedded by Th.
Theorem 3. T,, can be embedded into ZH(h + 1, h - 1, h - 3,. . . , 5, 3, 0) if h is even, and ZH(h +
1, h - 1, h - 3,. . . , 4, 1, 0) ifh is odd, where h 2 0.
Proof. We will prove the theorem by induction on
h.
Hypothesis : Th _ 1 can be embedded into
ZH(h, h - 2,. . . , 5, 3, 0) if h - 1 is even, and Th_l
can be embedded into ZH(h, h - 2,. . . ,4, 1, 0) if
h - 1 is odd.
Basis step (h = 0, 1, 2, 3): When h = 0 and 1,
T, and TI can be embedded directly into ZH(0)
and into ZH(l, 01, respectively. Moreover, when
h = 2 and 3, T, and T1 can be embedded into
ZH(3, 0) and Z1?(4, 1, O)-(see Fig. 2).
r2 - r3 - Th-I !LYiiih! Th-2
Fig. 3. Th is partitioned into one Th_l and two Th three subtrees are linked by double roots rl and r2.
C.-C. Chen, R.-J. Chen / Information Processing Letters 54 (1995) 69-72 71
(a) (b)
Fig. 4. (a) One Th_l and one Th_2 linked by double roots rl and r2, contained in a double-rooted complete binary tree of height h as (b).
Induction step: (1) When h is odd, T,, can be partitioned into three subtrees, one Th _ I and two
T ,, _*‘s as shown in Fig. 3. By Lemma 2, Hh + 1 contains a double-rooted complete binary tree of height h, which contains Th_ 1 and one Th_2
using double roots rl and r2, as shown in Fig. 4. By hypothesis, Th_* can be embedded into ZH(h
- 1, h - 3,. . . ,4, 1, 01, since h - 2 is odd. Hence, we can find the other Th_2 of T,, in ZH(h + 1, h
- 1, h - 3,. . . ,4, 1, 0).
Since any hypercube is symmetric, we can ad- just the double-rooted complete binary tree in
H h+l. Let the edge (r2, r3) of Th be mapped to the node r2 which is in Hh+l and the node r3
which is in ZH(h - 1, h - 3,. . . ,4, 1, 0); that is, the node r2 is established at the certain node in
H h+l, then the double-rooted complete binary tree can be constructed in Hh+l based on the node r2. Thus T,, can be embedded into ZH(h +
1, h - 1, h - 3, , . . ,4, 1, 0).
(2) Likewise, when h is even, T,, can be em- bedded into ZH(h + 1, h - 1,. . . ,5, 3, 0). 0
The compactness of the embedding is proved by the following theorem.
Fig. 5. IT(2,3).
Theorem 4. ZH(h+l,h-l,..., .5,3,0) if h is
even, or ZH(h + 1, h - 1, . . . ,4, 1, 0) if h is odd, is the smallest incomplete hypercube that contains Th.
Proof. The cases for h = 0, 1, 2 and 3 are trivial. For h > 4, if h is odd, and the total number of black nodes of Th are (2h+2 - 2)/3. The total number of black nodes in the embedded ZH(h + 1, h - 1,. . . ,4, 1, 0) is:
+ * * . + 24/2 + 272 + 20
=2h+2h-2+2h-4+ . . . +23+20+20
= (2h+2 - 2)/3.
So this embedded incomplete hypercube is the smallest.
Similarly, when h is even, ZH(h + 1, h - 1, h -3,... ,5, 3, 0) with (2hf2 - 1)/3 black nodes is the smallest into which Th can be embedded. •I
4. Embedding incomplete binary trees into com-
plete hypercubes
We denote an incomplete binary tree of height
h + 1 as ZT(h, n>, which is a complete binary tree of height h plus its leftmost n leaf nodes in level
h + 1, where 1 Q n < 2h+1 (see Fig. 5 for IT(2, 3)).
(a)
Fig. 6.
72 C.-C. Chen, R. -.I. Chen /Information Processing Letters 54 (1995) 69-72
Tzeng et al. [6] have shown that IT(h - 2, 2h-2) can be embedded into Hh. In this sec- tion, we present an embedding algorithm in The- orem 6 to find an incomplete binary tree in a hypercube, which is larger than the incomplete binary tree in [6]. To prove this embedding theo- rem, we need the following lemma.
Lemma 5. Two double-rooted complete binary trees
of height 2 in Fig. 6(a) can be embedded into H4
as shown in Fig. 6(b), where both the embedded
trees are linked by solid lines.
Theorem 6. IT(h - 2, 2h-2 + 2h-4) with 2h-1 +
2h-2 + 2h-4 - 1 nodes can be embedded into an h-dimensional hypercube, where h B 4.
Proof. First, Hh can be partitioned into two
Hh _ 1’s which are denoted H, and HI respectively according to the most significant bit. Each node of H, has an edge to link a certain node of HI. Applying Lemma 5 by letting x = n13, y = nl,,
z =n12, w =n14, x’=n,,, y’=nr2, z’ =nr4 and w’ = nr5, respectively, and based on the symmetry of the hypercube, two double-rooted complete binary trees of height h - 2 can be embedded into Hh as shown in Fig. 7 (The solid lines depict
. .
the edges which lmk n,3, nl,, n12 and n14 to n,,, n r2, nr4 and rq5, respectively).
We let A, B and C be the complete binary subtrees of height h - 3 rooted by n13, n14 and
n r3, respectively, B, be the complete binary sub-
h-4
B DI D2 E
HI H,
Fig. 7.
h-2
Fig. 8. The embedded incomplete binary tree IT(h - 2, 2h-2
+2h-4).
tree of height h - 4 rooted by n,4, D, and D, be the complete binary subtrees of height h - 5
rooted by nr7 and nr8, respectively, and E be the complete binary subtree of height h - 4 rooted by nr6. The incomplete binary tree constructed as shown in Fig. 8 can be embedded into Hh.
In addition, as there are h - 1 levels from root nr2 to either the leaves of its left subtree or the leaves of B,, and there are also h - 2 levels from root nr2 to either the leaves of D, or the leaves of E, the height of the incomplete binary tree rooted by nr2 is h - 1. So, the embedded incom- plete binary tree is IT(h - 2, 2h-2 + 2h-4). q
References
[I] H.P. Katseff, Incomplete hypercubes, IEEE Trans. Com- put. 37 (5) (1988) 604-608. I21 [31 [41 151 t61 [71
T. Leighton, Introduction to Parallel Algorithms and Archi- tectures: Arrays, Trees, Hypercubes (Morgan Kaufmann, Reading, MA, 1992) 406-408.
E.L. Leiss and H.N. Reddy, Embedding complete binary trees into hypercubes, Inform. Process. Lett. 38 (1991) 197-199.
L. Nebesky, On cubes and dichotomic Trees, dasopis Pest. Mat. 99 (1974) 164-167.
N.F. Tzeng, H.L. Cheng and P.J. Chuang, Embeddings in incomplete hypercubes, in: Proc. Znternat. Conf on Paral- lel Processing 3 (1990) 335-339.
AS. Wagner, Embedding the complete tree in the Hyper- cube, J. Parallel Distributed Comput. 20 (1994) 241-247. A.Y. Wu, Embedding of tree networks into hypercubes, J. Parallel Distributed Comput. 2 (1985) 238-249.