IEEE ON VOL. NO. MAY Rebalancing Balanced Trees · IEEE TRANSACTIONS ONCOMPUTERS, VOL. ... initial...

11
IEEE TRANSACTIONS ON COMPUTERS, VOL. C-27, NO. 5, MAY 1978 Rebalancing Height Balanced Trees FABRIZIO LUCCIO AND LINDA PAGLI Abstract-A new balancing technique for binary search trees is presented, based on the repositioning of k + 1 nodes (k-rotation) Some properties of k-rotation are shown, and bounds to k are derived. The performance of such a technique is discussed on the basis of the length of node search and the frequency of tree rebalancing. Index Terms-Height balanced trees, information storage and retrieval, rebalancing, rotation, search length. I. INTRODUCTION B INARY search trees are important structures for ordered data organization, since they can be searched through and updated in average logarithmic time. In addi- tion, if binary search trees are kept balanced in height, searching and updating are logarithmic operations even in the worst cases [1], [4], [5]. According to the general definition introduced in [3], height-balanced binary trees (Ahb-trees) have the property that, for every node, the heights of the right and left subtrees differ at most an integer A. lhb-trees are the well-known AVL trees. For a general value of A, tree restructuring after insertion or deletion of nodes may be accomplished by the classical operations (rotations) used for lhb-trees [3]. The average tree height-hence, the average search length- increases with A, while the average amount of restructuring decreases with increasing A. It is worthwhile to note, however, that restructuring may be required after the insertion (or deletion) of almost every new node. The worst case is the one of a tree growing by subsequent insertions of nodes presented in increasing order. Such a construction for a 3hb-tree composed of the alphabetically ordered nodes A to J is shown in Fig. 1: steps marked by a star required rebalancing. It can be easily proven that rebalancing is due at every step, except for the initial steps 1 to A, and for steps s = 2- 1 + A (k = 1, 2, -) where the new node is inserted into a perfectly balanced tree of 2k - 1 nodes with an additional rightmost chain of A - 1 nodes (in the example, s = 4, 6, and 10). Since during the insertion of n nodes (i.e., during the first n steps) the number of encountered steps of type s is [log2 (n + 1 - A)l rebal- ancing is due at n - [1lg2 (n + 1 - A)] - A steps, that is at 0(n) steps. Manuscript received August 17, 1976; revised May 5, 1977. This work was supported in part by the National Research Council of Italy (CNR) under Grant 75.01035.01. This work was partially done while F. Luccio was visiting the Department of Computer Science, University of Illinois at Urbana, IL. The authors are with the Istituto di Scienze dell'Informazione, Univer- sity of Pisa, Pisa, Italy. Obviously, the result in Fig. 1 is due to the balancing technique used. In [3], the idea of "balancing as closely as possible" versus classical balancing was briefly examined and discarded because of possible undesired effects. In this work we will resume this point, and thoroughly discuss alternative balancing techniques. Let hi denote the height of a tree i. For a node N with left and right subtrees iji and 0/, respectively, we classically define the balance bN as bN = h/, - hqi/. In a balanced tree, bN < A for each node N. We note that in Fig. 1 there is always at least one node N with bN = A = 3, except for the first A steps, and for steps 5 and 9 where the maximum balance is 2. For example, at step 7 it is bB = 3, and the successive insertion of node H unbalances node B, thus requiring rebalancing at step 8. Still, it results bE = 3, and rebalancing is newly needed at step 9. However, if a different rebalancing technique were adopted at step 8, by pulling node E at the root, the new configuration shown in Fig. 2 would be obtained, where the maximum balance is 2, hence no unbalancing may occur at the succeeding step. II. CRITICAL PATHS AND CRITICAL NODES To study the balancing technique we discuss some proper- ties of Ahb-trees. Let - be one such tree, ROOT(T) and LEAF(T), respectively denote the root and a leaf of -. For node K e T, let SON(K), LEFTSON(K), RIGHTSON(K), DESCENDANT(K), LEFTDESCENDANT(K), RIGHTDESCENDANT(K), and FATH- ER(K), respectively, denote a son, the left son, the right son, a descendant, a left descendant, a right descendant, and the father of K in Z. A path p E T is an ordered set of nodes {K1, K2, ..., Kr} such that Ki1, = soN(K1), 1 < i < r - 1. We denote p = K1, Kr; K1 = HEAD(P). r is the length of p. A single node is a path of length one. A node K E p is discordant with p if bK < 0, RIGHTSON(K) E p, or bK > 0, LEFTSON(K) E p; otherwise, K is concordant with p. (In particular, if bK = 0, K is concordant with p.) A path ROOT(T), LEAF(T) iS total. For a leafL, the total path containing L will be denoted by v(L). Definition 1: A path ir is critical if all its nodes are 0018-9340/78/0500-0386$00.75 C) 1978 IEEE 386

Transcript of IEEE ON VOL. NO. MAY Rebalancing Balanced Trees · IEEE TRANSACTIONS ONCOMPUTERS, VOL. ... initial...

IEEE TRANSACTIONS ON COMPUTERS, VOL. C-27, NO. 5, MAY 1978

Rebalancing Height Balanced TreesFABRIZIO LUCCIO AND LINDA PAGLI

Abstract-A new balancing technique for binary search trees ispresented, based on the repositioning of k + 1 nodes (k-rotation)Some properties of k-rotation are shown, and bounds to k are derived.The performance of such a technique is discussed on the basis of thelength of node search and the frequency of tree rebalancing.

Index Terms-Height balanced trees, information storage andretrieval, rebalancing, rotation, search length.

I. INTRODUCTIONB INARY search trees are important structures for

ordered data organization, since they can be searchedthrough and updated in average logarithmic time. In addi-tion, if binary search trees are kept balanced in height,searching and updating are logarithmic operations even inthe worst cases [1], [4], [5].

According to the general definition introduced in [3],height-balanced binary trees (Ahb-trees) have the propertythat, for every node, the heights of the right and left subtreesdiffer at most an integer A. lhb-trees are the well-knownAVL trees. For a general value of A, tree restructuring afterinsertion or deletion of nodes may be accomplished by theclassical operations (rotations) used for lhb-trees [3]. Theaverage tree height-hence, the average search length-increases with A, while the average amount of restructuringdecreases with increasing A.

It is worthwhile to note, however, that restructuring maybe required after the insertion (or deletion) of almost everynew node. The worst case is the one of a tree growing bysubsequent insertions of nodes presented in increasingorder. Such a construction for a 3hb-tree composed of thealphabetically ordered nodes A to J is shown in Fig. 1: stepsmarked by a star required rebalancing. It can be easilyproven that rebalancing is due at every step, except for theinitial steps 1 to A, and for steps s = 2- 1 + A (k = 1, 2, -)where the new node is inserted into a perfectly balanced treeof 2k - 1 nodes with an additional rightmost chain ofA - 1nodes (in the example, s = 4, 6, and 10). Since during theinsertion of n nodes (i.e., during the first n steps) the numberof encountered steps of type s is [log2 (n + 1 - A)l rebal-ancing is due at n - [1lg2 (n + 1 - A)] - A steps, that is at0(n) steps.

Manuscript received August 17, 1976; revised May 5, 1977. This workwas supported in part by the National Research Council of Italy (CNR)under Grant 75.01035.01. This work was partially done while F. Lucciowas visiting the Department of Computer Science, University of Illinois atUrbana, IL.The authors are with the Istituto di Scienze dell'Informazione, Univer-

sity of Pisa, Pisa, Italy.

Obviously, the result in Fig. 1 is due to the balancingtechnique used. In [3], the idea of "balancing as closely aspossible" versus classical balancing was briefly examinedand discarded because of possible undesired effects. In thiswork we will resume this point, and thoroughly discussalternative balancing techniques.

Let hi denote the height ofa tree i. For a nodeN with leftand right subtrees iji and 0/, respectively, we classicallydefine the balance bN as

bN = h/, - hqi/.

In a balanced tree, bN < A for each node N. We note thatin Fig. 1 there is always at least one node N withbN = A = 3, except for the first A steps, and for steps 5 and 9where the maximum balance is 2. For example, at step 7 it isbB = 3, and the successive insertion of node H unbalancesnode B, thus requiring rebalancing at step 8. Still, it resultsbE = 3, and rebalancing is newly needed at step 9. However,if a different rebalancing technique were adopted at step 8,by pulling node E at the root, the new configuration shownin Fig. 2 would be obtained, where the maximum balance is2, hence no unbalancing may occur at the succeeding step.

II. CRITICAL PATHS AND CRITICAL NODESTo study the balancing technique we discuss some proper-

ties of Ahb-trees. Let - be one such tree, ROOT(T) and LEAF(T),respectively denote the root and a leaf of-. For node K e T,let SON(K), LEFTSON(K), RIGHTSON(K), DESCENDANT(K),LEFTDESCENDANT(K), RIGHTDESCENDANT(K), and FATH-ER(K), respectively, denote a son, the left son, the right son, adescendant, a left descendant, a right descendant, and thefather of K in Z.A path p E T is an ordered set of nodes {K1, K2, ..., Kr}

such that Ki1, = soN(K1), 1 < i < r - 1. We denotep = K1, Kr; K1 = HEAD(P). r is the length of p. A singlenode is a path of length one.A node K E p is discordant with p if

bK < 0, RIGHTSON(K) E p,

or

bK > 0, LEFTSON(K) E p;

otherwise, K is concordant with p. (In particular, if bK = 0,K is concordant with p.)A path ROOT(T), LEAF(T) iS total. For a leafL, the total path

containing L will be denoted by v(L).Definition 1: A path ir is critical if all its nodes are

0018-9340/78/0500-0386$00.75 C) 1978 IEEE

386

LUCCIO AND PAGLI: REBALANCING HEIGHT BALANCED TREES

2A0

6

3A A

7*

4A

D

8* 9*

5*B

10B B D 0 D

AE

BF AjFEEAF H

Fig. 1. Steps for the construction of a 3hb-tree by subsequent insertionsof nodes presented in increasing order (classical rebalancing).

8*EO0

B .1 F .2A 0 +-1 1CO H0

Fig. 2. A new configuration at step 8 of Fig. 1 (balance values are shownhere).

concordant with i, and no other path 7' of all concordantnodes exists, such that r c i7r'.A critical path containing nodeK will be denoted by 7r(K).

We note that any critical path extends up to a leaf I, and isthe longest path containing L, composed of all concordantnodes. Hence, there is a one to one correspondence betweenleaves L and critical paths 7t(L).

Property 1: If two critical paths i 1, it2 contain a commonnode K, then they contain the common path

HEAD(7t1) HEAD(it2), K.

The proofimmediately follows from Definition 1. We notethat the common path extends up to a node M (possiblyM- K), with--bM =0; and that 7r1 and it2 must contain thesame number of nodes. In addition, any nonleaf node Mwith bM = 0 is contained in at least two critical paths.The sample tree of Fig. 3(a) contains the critical paths {A,

C, F, J, P, Q}, {B, D, H, K}, {B, D, H, L}, {B, D, I,IM},{E}, and{G}, which exhibit the above mentioned properties.

Let us now discuss the effects on T ofthe insertion of a newnode N. To ease future references, we will list some of theseeffects as formal properties. For a node K E z, let bK, hK orh/, and it(K), respectively, denote the balance of K, theheight of subtree f of root K, and a critical path containingK, all evaluated before the-insertion ofN. And let b'K, h'K orh'f, and i'(K) denote the same entities after the insertion ofN.

Property 2a: Let N be a new node to be inserted in T as sonof a nonleaf node Z.1 We have

i) b'Z _ JbZ + 1, if bZ < 0,if bZ > 0,

and, for any other node X E r, X * Zii) b'X = bX.

The proof of point i) is trivial. Point ii) follows from thefact that h'Z = hZ.

A *1

D,+ Eb Fi-3 0HO 91 13-2K 1;0 fiP-i-

QO

AO0B -

0- \ \P 0

(a) (b) (c)Fig. 3. (a) 3hb-tree and (b) the effect of insertion of a new node N as son

of a nonleaf, or (c) son of a leaf. Only the nodes whose balances arechanged are labeled in (b) and (c).

A new critical path it'(N) is generated as follows.Property 2b: Let N be a new node to be inserted in T as son

of a nonleaf node Z. We have

{N}, if IbZI >1,i) it'(N)= ((W) -{W}) u {N},

where W=SON(Z)7*N,if bZj = 1;2

ii) all the former critical paths of r are unchanged.The proof of point i) is trivial for bZ > 1, and follows

from Property 1 for bZ I = I by noting that b'Z = 0, henceZ becomes a common node of i'(W) and i'(N). Point ii)follows from Property 2a-ii).

In the example of Fig. 3(a) and (b), a new node N isinserted as son of a nonleaf P. It results: b'P = bP + 1[Property 2a-ii)], and it'(N) = {A, C, F, J, P, N} [Property2b-i)]. All other balances and critical paths are unchanged[Properties 2a-ii) and 2b-ii)].The insertion of N may cause more substantial

modifications in , if FATHER(N) is a former leaf of z.Property 3a: Let N be a new node to be inserted in T as son

of a leaf Z. For any node K E it(Z) we have

i) b'K

if bK < 0,if bK > 0,if bK = 0 and N = LEFTDESCENDANT(K),if bK = 0 and N = RIGHTDESCENDANT(K);

for node F =- FATHER(HEAD(it(Z))) (if exists), we have

ii) b'F - jbF + 1,if bF < 0,if bF > 0;

Before the insertion of N, node Z has exactly one empty subtree,where N is to be allocated.

2 If bZ = 1, then, before the insertion of N, node Z has exactly onedescendant W.

387

bK 1,bK + 11)

11)

+ 1 9

IEEE TRANSACTIONS ON COMPUTERS, VOL. C-27* NO. 5, MAY 1978

for any other node X E , X 0 7r(Z), X $ F, we haveiii) b'X = bX.

Point i) easily follows from the definition of 7c(Z) (Defini-tion 1). Point ii) follows from the fact that h'HEAD(7r(Z)) =hHEAD(lr(Z)) + 1, and HEAD(n(Z)) is the root of the shortersubtree of F. Point iii) follows from the fact that h'F = hF.

Property 3a shows that the balances of all the nodes on thecritical path r(Z) increase by one in absolute value, that is,such nodes are more unbalanced; and that the balance of Fdecreases by one in absolute value, that is, such a node ismore balanced.

Property 3b: Let N be a new node to be inserted in r as sonof a leaf Z. Let F = FATHER(HEAD(rt(Z))) (if exists).We have

i) ir(Z) u {N},

7r'(N)if HEAD(7r(Z)) _ ROOT(T) or bF I > 1,

HEAD(7r(F)), F u r(Z) u {N},if IbFI = 1;3

ii) for any node X E 7r(Z), X * Z, bX = 0, all thecritical paths 7t(X) containing S = SON(X) 0 nr(Z) are nomore critical; for any such S the new critical path is formednr'(S) = rr(X) - HEAD(l(X)), X;

iii) all the remaining critical paths are unchanged.Point i) is trivially proven for HEAD(9I(Z)) _ ROOT(7r) (i.e.,

F does not exist). IfF exists and bF > 1, then b'F * 0 andF is discordant with F, N [Property 3a-ii)], henceHEAD(n'(N)) = HEAD(lr(Z)). If I bF = 1, then b'F =0 and Fis concordant with F, N, hence HEAD(r(F)), F is included inir'(N). To prove poin inote that, after the insertion ofN,Xis discordant with X, S [Property 3a-i)], hence X 0 nr'(S).Point iii) follows from Property 3a-iii).

In the example of Fig. 3(a)-(c), a new nodeN is inserted asson of a leaf L. It results: b'L = + 1, b'H = + 1, b'D = -1,b'B = bB - 1 [Property 3a-i)]; bA = bA - 1 [Property3a-ii)]; rr'(N) = {A, B, D, H, L, N} [Property 3b-i)]; r'(K) ={K}, -r'(I) = {I, M} [Property 3b-ii)]. All other balances andcritical paths are unchanged [Properties 3a-iii) and 3b-iii)].

Properties 2a and 3a show that, for any node K E T, thebalance of K may increase in absolute value only if a newnode N is inserted in T as son of a leaf, and K E rr'(N). Wenow discuss how T may get unbalanced by node insertion.Let L be a leaf, a = a(L) be a total path, i.e., a = ROOT(T), LFor a node C E a, let K1, ., Kc} be the ordered set ofdiscordant nodes in C, L distinct from C. We define the pathbalance of C in a as

C -I bC - E IbKi |, if C is discordant with a,bC =< i-l

+ IbCI - E t bKi l, if C is concordant with a.

Definition 2: A node C is critical if there exists a total patha, C E a, such that, for any node K E a, K * C, we have

' Since F is not a leaf, 7r(F) may be nonuniquely defined. By Property 1,however, the path HEAD(nr(F)), F is uniquely defined.

or

and

bCa > bKa

bCa = bKa

hC < hK.

For any total path a, exactly one critical node C is definedthrough Definition 2, and will be denoted by C = CRIT(a);however for a1 $ a2 it may be CRIT(a 1) = CRIT(a 2). Hence,the number of critical nodes in T is at most equal to thenumber of total paths. Note that all discordant nodes havenegative path balances, while at least one node with non-negative path balance exists in a (namely, the leaf L E a hasbLa = 0): hence, CRIT(a) must be concordant with a, andbC, > 0.

In Fig. 4(a) we show a portion of z, consisting of a totalpath a. By Definition 2, we have B = CRIT(a).The relevance of critical nodes stems from the following

property.Property 4: Let / be a new tree ofheight h to be inserted in

z as subtree of a leaf L, and let C = CRIT(a(L)). If h = A +1 - bC,(L), then C becomes unbalanced, and no node of Tmay become unbalanced for smaller values of h.4

Proof: If there are no discordant nodes in C, L thenbCa(L) = IbC , and the property immediately follows. Ingeneral, let K1, , Kc and H1, , Hc, respectively, be thediscordant nodes, and their sons, in a(L), and letHo = ROOT(T) (possibly, Hi- Ki+ 1,0 < i < c -1); further-more, let b be the smallest integer such thatKb = DESCENDANT(C) 1 < b < c (i.e.,

C = DESCENDANT(Hb - 1)

or C _ Hb -1-). We have HEAD(Ir(L)) = Hc (Definition 1).Assume that / simply is a path {N1, ..., Nh}, h = A +1 - bC,(L), and that nodes N1, , Nh are added to T, one byone.' The following changes then occur in 'r. Set k = 0. Let abe the smallest integer such that

c

h . E |bKil,i=a

1<a<b<c6

(i.e. h <EI=a- 1 IbKi if a > 1). For j= c, c- 1, --,aconsider the following two steps:

i) if IbKjI > 1: the insertion of nodes Nk + 1, , Nk,k <WZbKI -1 yields

new bKj = bKj -(k-k) >0[Property 3a-ii)], and HEAD(7t(Nk)) = Hj [Property 3b-i)];

ii) set k = j bKi l; the insertion ofnode N, yieldsnew bKj = 0, and HEAD(7r(Nk)) = Hj- 1 [Property 3b-i)];

4 Obviously, C becomes unbalanced for h > A + 1 - bC.(L) also. Such acase, however, is not relevant in the following.

5 Besides proving the property, this procedure provides some insight inthe mechanism of updating critical paths and node balances.

6 Remember that C must be concordant with a(L), hencecc

h = A +1-bCa(L) =A + 1- IbCl + E IbKil > E IbKil.i=b i=b

388

LUCCIO AND PAGLI: REBALANCING HEIGHT BALANCED TREES

ROOT(Tt) I

A0-7(3)

X1 (- 4)

B*-6(3)

Y(2( -3)

D, O ( - )

E,*- l l )I-

LEO0 (0)

(-5) ROOTtLo+ I(-2)

% 7(5)

X< (- 2)

B' -6( 5)

2 -1((1)I C-4(4)

.1(1)

Es -3(3)

L -_2(2)N 2 }I 6

ROOT(t) 0

A,/

B-8

y 2

DO-4

1 -6

}5

(a) (b) (c)Fig. 4. Portion of a 7hb-tree (path balances are shown in parentheses).

(a) A total path E T: ROOT(T), X, Y, and Z are the discordant nodes,and B is the critical node. (b) and (c) Updating balances in a by inser-tion of a subtree .

upon exit from the cycle k=_ E= IbKi andHEAD(it(Nk)) =_Hai (since a < b we have in particularC it(Nt)). If k < h, nodes Nk+ 1, , Nk, k < h, are finallyinserted, yielding new bKa- I I = bKa 1 (k - k) > 0

if a > 1 and HEAD(l(Nk)) = Ha -I

During the insertion process, the balances of the nodes inl(Nk) are always increased in absolute value [Property3a-i)]; the balance of FATHER(HEAD(n(Nk))) is decreased inabsolute value (until it becomes 0, i.e., the node becomes partof nr(Nk), and its balance is henceforth increased in absolutevalue) [Property 3a-ii)] and no other balance is changed in T.

At the end of process (k = h) the following relations holdbetween final and initial balance values:

For any node M e Hc, L:{new bMI = IbMI + h = bMa(L) + h.

For any node (if any) M E Hj-1, FATHER(KA), c .j 2 a:

Inew bM| = IbMI + h-E=j IbK,I = bM,(L)+ h(in particular, new bC = bC,e(L) + h).

For any node Kj, c > j > a:

new bKjl = h D=j IbKi = bKjr(L) + h.If a > 1 (i.e., FATHER(HEAD(n(Nh))) = - )

c

inew bKa, II E bK1I -h =-(bK(a- U)a(L) + h).i =a- 1

For any other node of z, the balance is unchanged.

Hence, for any node M e ((L) we have Inew bM =

bMy(L) + h j, or (new bM) = bM.7 For any other node Rwe have new bR I = h-j (1 j < h) or (new bR) = bR.

Since h ='A +1-bCa(L) 2 A, and Inew bC I = bCa(L) +h = A + 1, then C becomes unbalanced at the end of theprocess, and no other node in T can be unbalanced forsmaller value of h (Definition 2).

If is not simply a path, all the above results still hold. Infact, a portion of ofheight k, 1 < k <h can be inserted in T

at any step, instead of path {N1, * *, Nk}. (In particular, nonode of can be made unbalanced.) O

After the insertion of tree # as in Property 4, node Cbecomes unbalanced together with all nodes C' (if any), suchthat C' a(L), bC'a(L) = bCG(L) and hC' > hC (see Definition

7 These relations show the practical meaning of path balance.

2). The relevance of C over such other nodes C' depends onthe balancing technique to be illustrated.The reader may verify Property 4, and its proof, on the

example of Fig. 4. In the tree of Fig. 4(a) we have A = 7,B = CRIT(4), bBa= 3. In the notation adopted to proveProperty 4, we have K1 = ROOT(T), K2 = X, K3= Y,K4=Z, Ho0 K1 =ROOT(T), H1=A, H2=B, H3=C,H4 = E; c=4, b = 3 (in fact, B = CRIT(U)=-H2);HEAD(It(L)) = E. We set h = A + 1 - bBa= 5, hence a = 1(h 1 bKi I). We start inserting /={N ,}, sinceI bK4 1 = bZ = 1, step i) of the proof is skipped, andN1 isinserted in step ii) yielding Inew bZI = 0, andHEAD(7r(N1))= C. Node N2 is inserted in the succeedingstep i): the resulting situation is shown in Fig. 4(b). After awhole tree / of height h has been inserted, the situation ofFig. 4(c) results: note that new bB = 8, that is the criticalnode is unbalanced. Note also that I new bA I = 8, that isanother node of a is unbalanced, where bAa = bBff = 3 andhA > hB.

Property 4 shows how r gets unbalanced by insertion of asubtree X of a given leaf 4, where C = CRIT(a(L)) is the nodeunbalanced for a vr of minimal height h. However, ifC 0 i(L), there exists at least one leaf L * 4, C E r(L').Therefore C is unbalanced by the insertion of a subtree 1' ofL of height h', h' = A + 1 - bC I < h. Obviously, i' is theshortest subtree whose insertion in T causes unbalancing ofC.

In the following we examine the single node insertionwhich unbalances T (e.g., the insertion of the last node of /,which makes f of height h).

Property 5: Let N be a new node to be inserted in T as sonof node L, and let C = cRIT(a(L)). Tree r becomes unbal-anced if and only if L is a leaf, C E ir(L) and IBC =A.

Proof: L must be a leaf by Property 2a. By substitutingh = 1 in Property 4, we have bC,(L) = A. Since C is concor-dant with v(L), we have by definition bCW(L)= fbCj-

1 bK I,where K, * K, are the discordant nodes (ifany) in C, L Combining the above relations with bC I < A,we have I bC I = A and Ef= I bKi I =0, that is no Ki exists,hence C is in the critical path ir(L).

III. REBALANCING BY ROTATION

The classical restructuring operation on Ahb-trees is therotation, that is reordering of the nodes of a path composedof the critical node and one or two of its descendants. A newmore general rotation will now be defined.As in Property 5, let N be a new node to be inserted in z as

son of a leaf L, and let C = CRIT(a(L)), C e i(L), andbC I = A. After the insertion of N, node C is unbalanced,

while C, L c i'(N) [Property 3b-i)], and b'B * 0 for eachnode B E C, L [Property 3a-i)]. For any such node B E C, 4,B# C, letFCB± ={Cl+, C2+,, CP+} andFCB- = {C1_,C2 _, * , Cn_} be the ordered sets of nodes in C, FATHER(B),such that b'Ci+ > 0, 1 < i < p, and b'Ci- < 0, 1< i< n;and let rCB1 and TBr be the left and right subtrees of B,

389

respectively.

IEEE TRANSACTIONS ON COMPUTERS, VOL. c-27, NO. 5, MAY 1978

Definition 3: For k = p + n, a k-rotation C-B consists ofthe following changes in T:

a) replace B for C;8b) set LEFTSON(B) = C1, and RIGHTSON(B) = Cj_;c) set RIGHTSON(Ci+) = C(i+1)+, 1 < i < p- 1i and

LEFrSON(Ci-)= C(i+ 11_ 1 < i < n- 1;d) set RIGHTSON(C,+) = ROOT(TBI) and

LEFTSON(Cn -) = ROOT(TB,).k is called the length of rotation. A k-rotation C-B is

illustrated in the example of Fig. 5. The classical single anddouble rotations are particular instances of k-rotation withk = 1 or k= 2.While unprimed, or primed, symbols indicate entities

before, or after, the insertion of N, a double prime super-script will denote such entities after a k-rotation.Our aim is to apply k-rotation to rebalance T. In fact, for

any value of k, such a rotation maintains the binary searchtree property on the ordering of nodes. However, theresulting values of node balances must be carefullyexamined. First we discuss a condition under which no treecan be rebalanced by a k-rotation.

Definition 4: For a given path C, B, a path 4 c C, B ismonotone if all its nodes have balances of the same sign, andno other path q/ c C, B exists, such that / v 4, and all thenodes of i/ have balances of the same sign.

Theorem 1: No Ahb-tree can be rebalanced by a k-rotation C-B, if the- path C, FATHER(B) contains a mono-tone path 4 of length m > 2A.

Proof: Letting T' and T", respectively, denote theconfigurations of a tree after the insertion ofN, and after thesubsequent k-rotation, we look for a node that cannot bebalanced in z". Let 4 = {K1, *, Km,} m . 1. We distinguishtwo cases, namely, K1 # C and K1 C.Case l-K1 O C: Refer to trees T', T" of Fig. 6(a) (or to the

symmetric trees, with negative balances on 4). In T' we haveF = FATHER(K1) E C, B, and possibly ROOT(T) _ C, C Fand RIGHTSON(Km)_ B. We have Ib'CI = A + 1, hence:

1.< b'FI <A+1. (1)

In ", subtrees Ty and Tzare composed ofthe nodes ofsubtreerx of T', except for node B. According to the k-rotationmechanism, it results:

h"y < h'Tx-1; (2)

h"Tz < h'Tx-1. (3)

Since b'F < 0, and b"F > b'F [by relation (3)], then F isbalanced in T" if and only if b"F < A. We havehTF + Ib'FI = m + h'Tx, hence, b"F = hTF- h"Tz = m +h'- b'F -h"z. By substituting in this relation thelower bounds for - b'F [relation (1)] and h'-x -h"z[relation (3)], we obtain b"F > m - (A + 1) + 1. Combiningthe last relation with b"F < A, we have m < 2A, which is the

8 That is, B takes the place of C as son of FATHER(C), or B becomesROOT(T) if C = ROOT(T).

tiyr

(a) (b)Fig. 5. Example of k-rotation. (a) A portion of T after the insertion of N.

(b) The effect of a 6-rotation B-C.

bound beyond which node F cannot be balanced in any treeT,Case2-K1C: Refer to trees r', T" of Fig. 6(b) (or to the

symmetric trees with negative balances on 4). In T', it iSpossible that ROOT(=-') K1 and RIGHTSON(Km). B. Onlynode K1 is unbalanced in K1, N, hence,

b'K1= A + 1; 1 < b'Ki < A 2 < i <m. (4)

For the heights of subtrees TX, Ty. and TZ, relations (2) and(3) still hold.

Since b"B < h"rz- hTm < h'Tx- hTm [relation (3)], andh'Tx - hTm = b'Km < A + 1 [relations (4)], then

b"B < A + 1,that is B is balanced in T" if and only if b"B . - A. We haveb"B = h"T- m -max (hTm h"-Y). From relations (4), weobtain hTm h'Tx- b'Km > h'Tx- A - 1 (the equal signholds for m= 1), while there exist trees where h"Ty isarbitrarily small. Hence, in any case b"B < h"Tz- m -(h'Tx - A - 1), and by substituting in this relation the upperbound for h"Tz- h'Tx [relation (3)], we have b"B < - m + A.Combining the last relation with b"B> -A, we havem < 2A, which is the bound beyond which node B cannot bebalanced in any tree T" (such a bound coincides with thebound for F in Case 1). EThe bound presented in Theorem 1 is strict, since there

exist trees with m = 2A that are rebalanced by a k-rotation(an example is given below). In fact, while the bound hasbeen derived for the nodes F and B (Cases 1 and 2 in theproof of the theorem), it can be provedthat no othernode ofT" imposes further bounds on m in the general case.The bound m < 2A can be sharpened in various cases, if

special conditions on the nodes of C, B hold, however, nofurther investigation on this point will be carried out here.Theorem 1 shows that the length of monotone paths,

rather than the length of C, B, is a limiting factor for thelength of a k-rotation. Thus, somehow unexpectedly, ak-rotation with k > 2 may occasionally rebalance an AVLtree, as in the example of Fig. 7 where X, Y is a monotonepath of length 2A = 2.

390

LUCCIO AND PAGLI: REBALANCING HEIGHT BALANCED TREES

(a)

tx (b)Fig. 6. Study of a bound to the length of k-rotation. (a) Case 1: C # KI.

(b)Case2: C=K1.

ty

Let us now discuss new conditions on C, B, under which ak-rotation does not unbalance the nodes of z". Recall thatany node of C, FATHER(B) belongs to one of the two setsFcB+ = {Cl+, CP+}FcB-= {Cl ., ,Cn_l,p+ n = k.First, we study the balancing ofthe nodes ofC, FATHER(B) int".

Theorem 2: If k<A+2- Ib'B|, no node ofC, FATHER(B) can be unbalanced by a k-rotation C-B.

Proof: Refer to Fig. 5. The balance of all nodes of IcB+(or TCB ) decrease (or increase) after a k-rotation, hence anysuch node may become unbalanced only if the sign of itsbalance changes. That is, the nodes in C, FATHER(B) arebalanced after a k-rotation if and only if

bCi>+2-A,b"Ci_ <A,

1 . i < p;

1 < i < n.

(5)(6)

Without loss of generality let b'B < 0.9

For a node Ci +, b"Ci + reaches its minimum value if, in -r",TBI contains the deepest node ofthe right subtree ofCi [Fig.8(a)]. That is,

b"Ci+ . b'Ci+ - q - 1,

where q is the number of nodes of type Cj_ in

RIGHTSON(Ci+), FATHER(B)

in z', and the quantity - q - 1 accounts for the fact that suchnodes, and node B, do not belong to the right subtree ofCi +in r". The right-hand side of the above relation takes itsminimal value if b'Ci+ 1 (implying that Ci, is not thecritical node C), apd q = k -2 (that is, in z'C = FATHER(Ci+), and all the k - 2 nodes in

RIGHTSON(C;+), FATHER(B)

are of type Cj-). Hence,

bIICi+ 2 1-(k-2)-1 = -k + 2.I Symmetrical results hold for b'B > 0, yielding the same bound for k. Combining this inequality with (5), we have

391

IEEE TRANSACTIONS ON COMPUTERS, VOL. C-27, NO. 5, MAY 1978

tBL-C

(b) (c)Fig. 7. (a) An AVL tree T', unbalanced by insertion of node N. (b) z after

a classical (double) rotation. (c) T' after the 4-rotation C-B.

(a)

where r is the number of nodes of type Cj+ in

LEFTSON(Ci_), FATHER(B)

in T'. The right-hand side ofsuch a relation takes its maximalvalue if b'Ci_ = - 1 (implying that Ci is not the criticalnode C), and r = k - 2. Hence,

b"Ci < -1 + (k -2) + 1 + I b'BI = k -2 + Ib'BI.Combining this inequality with (6) we have

k<A+2- (b'BI (8)

(b)Fig. 8. Study of node balancing in C, FATHER(B).

k < A + 2 (7)which gives a bound under which no node Ci+ can beunbalanced in T".

For a node Ci_, b"Ci - reaches its maximum value if, in T",TB7 contains the deepest node of the left subtree ofCi [Fig.8(b)]. That is,

b"Ci_ < b'Ci- + r + 1 + (h TBI- hTBr)= b'Ci + r + 1+ Ib'BI,

which gives a bound under which no node Ci_ can beunbalanced in T". Obviously, relation (7) gives the overallbound to k. gThe balancing of node B in T" is studied in the following

theorem.Theorem 3: If

b'C<O and n<A-Ib'BIor

b'C>O and p<A- Ib'BI,node B cannot be unbalanced by a k-rotation B-C.

Proof:1) Let b'C < O, that is C _ C1, b'C -(A + 1). Refer-

ring to Fig. 5, it can be easily shown that b"B > b'C; hence,node B is balanced after a k-rotation if and only if

b"B < A. (9)b"B reaches its maximum value if a) the right subtree ofB inz" has the same height as the left subtree ofC in ' (i.e., such asubtree of B has maximum height); b) hTBl < hTB; and c) TBIcontains the deepest node of the left subtree of B in z" (i.e.,

392

LUCCIO AND PAGLI: REBALANCING HEIGHT BALANCED TREES

Fig. 9. Study of balancing of B.

X0 G -I 4

Ei -1 G10110

/3~~~~~~~~~~~~~~~~~~~~~~~~

N y

Fig. 10. The effect of 2-rotation, 3-rotation, and 4-rotation on a 3hb-tree.

such a subtree of B has minimum height) (Fig. 9). That is,b"B < (k + hTzB) - (p + hTBl) = n + Ib'BI, (10)

where the term (k + hTBr) is the height ofthe left subtree ofCin ', which is a bound for the height of the right subtree ofBin l'; and the term (p + hTBL) is the height of the left subtreeofB in T". Combining relations (9) and (10) we have n < A -b'B l, which gives a bound under which node B cannot be

unbalanced in ", for C _ Cj.2) In the case b'C > 0 a symmretrical reasoning can be

carried out, yielding the result p < A - b'B 1. DExamples of k-rotation, and the application ofTheorems

2 and 3, are shown in Fig. 10. Node N has been inserted inthe 3hb-tree T', thus unbalancing the critical node C. Byperforming on T' the 2-rotation C-E, the 3-rotation C-F orthe 4-rotation C-G, the trees T'2, T-', and Tz, respectively,result. For k = 2 Theorems 2 and 3 apply to z', hence T'" iSbalanced. For k = 3 and k = 4, Theorem 2 applies to T',hence nodes C, D, E, and C, D, E, F are balanced in T and T",respectively. However, for k = 3 and k = 4 Theorem 3 doesnot apply to T', that is, nodes F and G are not necessarilybalanced in z" and z", respectively. (In the example suchnodes are actually balanced: see below.)

Note that 1-rotation does not apply to z' since node Dwould be unbalanced. In fact, Theorem 3 does not apply inthis case.

Since k > n, p, we can state the following corollary ofTheorem 3, giving a simpler, but less strict, condition onC, B.

Corollary: If k < A - b'B|, node B cannot be unbal-anced by a k-rotation B-C.The bounds for n and p in Theorem 3 are strict, but n and p

reach such values in special cases only (Fig. 9). In particularTheorem 3 does never apply to AVL trees, where b'B = 1,yielding n = p = 0. Such bounds may be sharpened inspecial cases (and may become relevant to AVL trees too).We merely add here the following result.

Corollary: For k > 2 if

b'C <0, b'LEFrSON(C)>0 and n <A - Ib'BI + I

or

b'C > 0, b'RIGHTSON(C) < 0 and p < A- Ib'BI + 1,

node B cannot be unbalanced by a k-rotation B-C.The proof derives from the proof ofTheorem 3, by noting

that, for b'C < 0, the height ofthe right subtree ofB in T" is at

393.

394IEE TRANSACTIONS ON CoMPUTERS. Vol.. c-27. No. 5. MAY 1978

c-cl i

h'C = hC.1

Fig. 13. Illustration of node balancing on a 2hib-tree.

Fig. 11. Study

h2

hc

tfBof/it"B.

teatel

Fig. 12. Study of lower bound to h"B with b'B < 0.

most equal to height ofthe left subtree ofC in ' minus one. Asimilar proof holds for b'C > 0.

In the example of Fig. 10, the latter corollary applies to T'for k = 3 and k = 4. Hence, nodes F and G must be balancedin zT and t4, respectively.

In addition to the nodes in C, B, only the ancestors of Cmay be influenced by the k-rotation. In fact, since B takes theplace of C after rotation, the balances of the ancestors ofCmay be varied, if h"B $ hC. The bounds for h"B are given inthe following properties.

Property 6: h"B < hC + 1. In particular, h"B = hC + 1if and only if

i) C, FATHER(B) is a monotone path in z' and b'B andb'C have different sign; or

ii) there exists a node Q E C, FATHER(B) such that C, Qis a monotone path and b'Q = 1.The proof can be immediately derived by the inspection of

Fig. 11 [point i)] and Fig. 9 [point ii)].Property 7: h"B > hC - q, where

q = min (A-l, n- l,p- + Ib'B), for b'B < 0;

q=min (A- l,p- 1,n- 1 + Ib'BI), for b'B>O.

Proof: Refer to Fig. 12, with b'B < 0. From T' we derivehTz = hC-A- 1; hTB = hC-k; hTBr= hC-k- Ib'BI.Hence, from T" we have h1 = hrT + 2 = hC - (A - 1);h2 = hTB + p + 1 = hC-(n- 1); h3 = hTBr + n + 1 =hC - (p -1 + Ib'B I). Since it must be h"B . max (h1, h2,h3), the property follows for b'B < 0. A similar reasoningholds for the case b'B > 0. D

Since k.> w. that is k - 1 > min( - 1, p - I + I'B I),and k - 1 > min (p - 1 p - 1 + Ih'BI), we can state thefollowing corollary of Property 7, giving a simpler but lessstrict bound on hi"B.

Corollary: hi"B > C - min (A - 1, k - 1).Based on the upper bound of lh"B of Property 6, we can

state the following theorem.Thieorem 4: A node Q E HEAD(ir(C)), FATHER(C) in T is not

unbalanced by a k-rotation B-C, if and only if bQ + A orh"B $ hC + 1.

Proof: If h"B= hC + 1 then Ib"QI = IbQI + 1.Hence, Q is unbalanced in -r" if and only if bQ = A. In anyother case, Q is not unbalanced in T". In fact, by Property 7we have h"B > hC - q, that is the height of the highestsubtree of Q in T' is decreased at most q < A in r". D

Let F = FATHER(HEAD(r(C))) in z. Based on the lowerbound of h"B of Property 7, we state the following.

Thteorem 5: If bF < A - q, then F is not unbalanced bya k-rotation B-C.

Proof: Since F is discordant with F, B in r, then theheight of the shortest subtree of F in r is decreased by ak-rotation at most q in 'r" (Property 7). Hence, b"FI <bF + q, and b"F < A for F to be balanced, that isIbF <.A-q. oAn application of Properties 6 and 7, and Theorems 4 and

5, is illustrated in the example of Fig. 13. In the 2hb-tree z wehave H = HEAD(7r(C)) FATHER(C) and

F = FATHER(HEAD(7t(C))).

Node N is inserted in the right subtree of B, thus unbalanc-ing C; a 3-rotation C-B is then performed, giving rise to treer". It results h"B = hC - 1, that is Property 6 is verified(points i) and ii) do not apply), and H must be balanced in z"by Theorem 4. (In fact, b"H = + 1.) Since b'B = + 1, p = 2,n = 1, we have q = 1 in Property 7, hence, such a property isverified with the equal sign. Finally, bF = 1 = A - q, thenF must be balanced in r" by Theorem 5. (In fact, b"F = -2.)Note that, if the left subtree of F were higher by one, that isbF = -2, we would have b"F = -3, that is F would beunbalanced in T". In fact the condition ofTheorem 5 wouldnot be satisfied in such a case.

All the nodes Q E -, Q 0 FATHER(HEAD(r(C))), B, are notaffected by the insertion of N in r, and by the subsequentk-rotation C-B: that is, bQ = b'Q = b"Q. See for examplenode R in the tree of Fig. 13, where bR = b'R = b"R = 0.Therefore, the conditions under which r" is balanced aregiven by Theorems 2-5, which are relative to the nodes ofFATHER(HEAD(nr(C))), B.

394

LU'CCI() AND PAGLI: REIIALANCING HEIGHT IBALANCED TREES

IV. SELECTION OF THE LENGTH OF ROTATION AND

CONCLUDING REMARKS

In the last section we have discussed bounds to the valueof k, under which a tree can be rebalanced by a k-rotation.However, we have not given a criterion to select the value ofk.

The choice of the rotation obviously depends on the goalto be reached, namely, decreasing the number of futurerebalancings of the tree and/or decreasing the average

search length in the tree.Since a node Q can be unbalanced by subsequent inser-

tions of A + 1 - bQ nodes at the end of nr(Q),'0 and no

smaller number of nodes can unbalance Q, then the follow-ing (worst case) criterion insures that rebalancing of T" willnot be required for the maximum number of future nodeinsertions.

Criterion 1: For Q E F, B in 1, F = FATHER(HEAD(n(C))),minimize maxQ b"Q as a function of k.

In fact, it has been shown in the previous section that onlythe nodes Q E F, B are such that b"Q $ bQ.The search length is a logarithmic function of the number

of nodes of T, even in the worst case. However, if decreasingthe average value ofsuch a search length is a goal on the tree,the following (average case) criterion may be adopted.

Criterion 2: For all Q e C, B in T, maximize

EQ (I'Q-I "Q) as a function of k, where lQ is the level of Q(i.e., the length of the path ROOT(T), Q).

In fact, from Fig. 5 it is clear that the variation of theaverage search length depends upon the nodes of FcB+(FcB-) and of their left subtrees (right subtrees), and uponnode B change in T-" with respect to '.

In the example of Fig. 10, Criterion 1 is satisfied by k = 3and k = 4, since, for all Q E C, G in T', we havemaxQ IbQI = 2 in T", and maxQ Ib"Q 1 in Tz and T"'.Criterion 2 is satisfied by k = 3, since EQ (I'Q - 1"Q) = 3 inTz and T"' and EQ (lQ - I"Q) = 4 in T f.

Let us now discuss the computational cost of applicationof Criteria 1 and 2. We will give the orders of magnitudehere, without getting into intricate details, which essentiallyregard the implementation of the balancing algorithms.

Criterion 1: For a given value of k, from the definition ofk-rotation we have

1) b"F = b'F + (h'C - h"B), hence the cost of com-puting |b"F is constant;

2) for any Q E H, K in T, where H = HEAD(t(C)) andK = FATH'ER(C), we have Ib"QI = Ib'Q -(h'C-h"B)I,hence,

max Ib"QI = max (p, q),Q E H,K

wherep = |max Ib'Q -(h'C-h"B)I,

Q H,K

qI= min b'QI -(h'C-h"B)I;Q E H,K

10 That is, Q is unbalanced by the insertion of a subtree E of heighth = A + 1- IbQ ,constituted of a path of A + 1- IbQ I nodes (see Sec-tion II).

since, for Q E H, K, max b'Q and min |b'Q can becomputed while traversing T to allocate N, then the cost ofcomputing

max Ib"QQ e H.K

is constant;3) the k-rotation is obviously an operation of order k,

hence the cost of computing

max Ib"QQ E C,B

is linear with k.Therefore the cost of evaluating

max Ib"QQ E F,B

is a linear function of k, that is the cost of minimizing such afunction, as required by Criterion 1, is a quadratic functionof k.

Criterion 2: For a given value of k, the cost of computingl'Q - 1"Q is constant for any Q E C, B, hence the cost ofcomputing

E ('Q - I"Q)Q

is a linear function k.Therefore, the cost of maximizing such a function, as

required by Criterion 2, is a quadratic function of k.Theorem 1 gives the bound- of 2A on the length of

monotone paths in C, B, beyond which z cannot be rebal-anced by a k-rotation, however, no similar limitation can beposed on k. That is, there exist trees rebalanced by ak-rotation C-B, where B N (in which case k may be ofO(log n), where n is the number of nodes of T). The readermay easily build an example of such a tree, by appendingnodes alternatively belonging to FCB+ and 1cB- as descen-dants of node Z, in the AVL tree of Fig. 7(a).

As a consequence, if the bound O(log n) is applied to k, theapplication of Criterion 1 or 2 may involve a computation ofO(log2 n), which is generally not desirable.

Conversely, let the bounds given in Theorems 2-5, andrelated corollaries, be imposed to k. Since all such boundsare of 0(A), Criteria 1 and 2 involve a computation of O(A2),which can be regarded as a constant for any given tree. Inaddition, the tree is certainly rebalanced by such a k-rotation. Hence, we propose to apply such bounds to k.As a final remark, we note that this work is centered on the

definition and the properties of k-rotation, while the actualuse of such a rotation is largely left to the needs of anyparticular application.

REFERENCES[1] D. E. Knuth, The Art of Computer Programming, vol. 3. Reading, MA:

Addison-Wesley, 1973.[2] J. Nievergelt, "Binary search trees and file organization," Comput.

Surveys, vol. 6, pp. 195-207, Sept. 1974.[3] C. C. Foster, "A generalization of AVL trees," Commun. Ass. Comput.

Mach., vol. 16, pp. 513-517, Aug. 1973.

395

IEEE TRANSACTIONS ON COMPUTERS, VOL. c-27, NO. 5, MAY 1978

[4] F. Luccio and L. Pagli, "On the height of height balanced trees," IEEETrans. Comput., vol. C-25, pp. 87-90, Jan. 1976.

[5] P. L. Kariton, S. H. Fuller, R. E. Scroggs, and E. B. Kaehler, "Perfor-mance of height balanced trees," Commun. Ass. Comput. Mach., vol.19, pp. 23-28, Jan. 1976.

4.

Fabrizio Luccio received the Laurea in electricalengineering in 1962 and the Libera Docenza inelectronic computers in 1968, from the Poly-technic of Milan, Milan, Italy.

In 1962 he was with the Laboratorio RicercheElettroniche of Olivetti, Italy, working on switch-ing circuits. From 1964 to 1970 he was on theFaculty of the Polytechnic of Milano. Since 1971he has been with the Istituto di ScienzedellInformazione at the University of Pisa, Pisa,Italy, where he has served as Chairman for three

years, and is currently a Professor in Computer Science. His mainfield of interest currently is the theory of information structures and

algorithms. He has also been Visiting Staff Member at MassachusettsInstitute of Technology, 1966/1967, and Visiting Professor at theUniversity of Southern Calffornia in 1967, New York University in1969/1970, U.C.L.A. in 1972, and the University of Illinois at Urbanain 1976.

Dr. Luccio is a member of Association for Computing Machinery andthe Associazione Italiana Calcolo Automatico.

Linda Pagli received the Laurea in informationscience from the University of Pisa, Pisa, Italy, in1973.

Since 1973 she has been associated with theIstituto di Scienze dell'Informazione of the Uni-versity of Pisa, as a Research Associate andTeaching Assistant. Her present interests are inthe theory of information structures and databases.

Asynchronous State Assignments with UnatenessProperties and Fault-Secure Design

DHIRAJ K. PRADHAN, MEMBER, IEEE

Abstract-Techniques to construct standard state assignmentsthat yield inate next-state functions are presented. These proposedssignments use Berger codes. It is established that for any N row

flow table, it is possible to construct (2,1)-and (2,2)-like assignmentswhich require ss than

n2 + 3n + 2n 10g2 n n3-4n + 3n2 + 6n2 log2 n2 and 6

variables, respectively, where n = 10g2 N. ' Further, it is also shownhow to modify the so-called (2n + 1) type assignment for unateness.The modified assignments require 2[n + I + 10g2 (n + 1)] variables

Finally, a procedure to design fault-secure asynchronous networksis presented. The ssignments proposed in this paper are shown to beuseful for this designL

Index Terms-Asynchronous networks, Berger codes, fault detec-tion, fault-secure networks, self-checking checker, self-checking

Manuscript received January 3, 1977; revised August 12, 1977. Thisresearch was supported in part by the National Research Council underGrant A8981 and by the National Science Foundation under Grant76-84571.The author was with the Department ofComputer Science, University of

Regina, Regina, Sask., Canada. He is now with the Department of Electricaland Computer Engineering, Wayne State University, Detroit, Ml 48202.

X In this paper, log2 x will represent [log2 x] where [s] denotes thesmallest integer greater than or equal to s.

networks, single-transition-time assignments, unate next-state func-tions, unidirectional faults, universal assignments, upper bound onthe number of state variables.

I. INTRODUCTIOND ESIGN of sequential machines with unate next-stateDJ functions, in the context of fail-safe design [5], [6], [12]has been considered by several authors. More recently, thisparticular problem ofunate next-state functions was studiedextensively by Mago [1]. In addition to purely theoreticalinterests, there is considerable practical motivation for thisstudy. As it will be seen, unate next-state functions not onlyhave fail-safe properties, but also have fault-secure prop-erties [1]. A contribution in Mago's paper was the extensionof Friedman et aL's [2] technique to construct universalassignments (suitable for any flow table) which produceunate next-state functions. In [1], no closed formulae for thenumber of variables required for such assignments werederived.

In our paper, precisely such expressions are deduced,using Berger codes, and their asymptotic properties areidentified. Next in this paper, anew technique is obtained formodifying a class of double-transition time assignments, sothat they yield unate next-state functions.

0018-9340/78/0500-0396$00.75 C) 1978 IEEE

396