Running head General Balanced Trees Author's address Arne Andersson Department of Computer Science Lund University BOX 118 S-1 00 Lund Sweden

Size: px
Start display at page:

Download "Running head General Balanced Trees Author's address Arne Andersson Department of Computer Science Lund University BOX 118 S-1 00 Lund Sweden"

Transcription

1 General Balanced Trees Arne Andersson Department of Computer Science Lund University Sweden 1

2 Running head General Balanced Trees Author's address Arne Andersson Department of Computer Science Lund University BOX 118 S-1 00 Lund Sweden

3 Abstract We show that, in order to achieve eæcient maintenance of a balanced binary search tree, no shape restriction other than a logarithmic height is required. The obtained class of trees, general balanced trees, may be maintained at a logarithmic amortized cost with no balance information stored in the nodes. Thus, in the case when amortized bounds are suæcient, there is no need for sophisticated balance criteria. The maintenance algorithms use partial rebuilding. This is important for certain applications, and has previously been used with weight-balanced trees. We show that the amortized cost incurred by general balanced trees is lower than what has been shown for weight-balanced trees. 3

4 1 Introduction One of the fundamental data structures in computer science is the binary search tree. New methods to maintain data in search trees have been developed and thoroughly analyzed all through the history of the discipline. Attention has mainly been focused on trees with bounded height or balanced trees. The reason for this is obvious since worst-case access time is proportional to the height of a tree. The traditional way to maintain balance at a low cost is by means of some more os less sophisticated balance criterion. To illustrate the large variation in the world of balance criteria some examples are given below. We use jt j to denote the number of leaves èweightè of the tree T. AVL-trees, introduced by Adelson-Velskii and Landis ë1ë, are deæned by a balance criterion requiring the heights of the two subtrees of each node to diæer by at most 1. AVL-trees have a maximum height of 1:44 log jt j. Symmetric binary B-trees, or SBB-trees, were introduced by Bayer ë6ë. The very same class of trees often occurs under the name red-black trees, due to Guibas and Sedgewick ë14ë. The edges in an SBB-tree are of two types: horizontal and vertical. Two adjacent edges are never both horizontal and the number of vertical edges on the path from the root to a leaf is the same for all leaves. This criterion guarantees a maximum height oflogjt j. Weight-balanced trees were introduced by Nievergelt and Reingold ë0ë. For each nodein the tree, the ratio of the weights of its two subtrees is restricted. Given a parameter æ, 0 æé1=, for each nodev in the tree, the quotient between the weight of èi.e. the number of leaves inè v's smallest subtree and the weight of v itself must be at least æ. The maximum height ofaweight-balanced tree is log jt j log 1 1,æ æ-balanced trees were introduced by Olivie ë1ë. These trees are path-balanced. Given a parameter æ, 0éæé1, for each node in the tree, the quotient between the lengths of the shortest and longest outgoing paths must be at least æ. This guarantees a maximum height of log jt j æ. kíneighbour trees were introduced by Maurer, Ottmann, and Six ë18ë. They are unarybinary trees where all leaves have the same depth. The number of binary nodes between two unary nodes at the same level is at least k. A k-neighbour tree has a height ofatmost log jt j. logè,1=èk+1èè For each of these classes of trees, computing the maximum height from the balance criterion is a nontrivial exercise. Other examples of balanced trees are HBèkè-trees ë1ë, one-sided height-balanced trees ë15, 16ë, and SBBèkè-trees ë4ë. Note that the splay trees, introduced by Sleator and Tarjan ë4ë, are not strictly balanced since the height of a splay tree T may be æèjt jè. A natural question that arises from the study of balanced trees is whether we really need to make a detour over those balance criteria when the only thing we want èmostlyè is a logarithmic height. The disadvantage of using a sophisticated criterion is illustrated by. 4

5 Figure 1: A well-balanced tree? the tree in Figure 1. This tree has the smallest possible height with respect to its weight; however, according to the balance criteria mentioned above it is not well-balanced at all. In this article we show that, as long as we are concerned with the amortized cost of maintenance, we can replace the criteria above by a weak global criterion; we just have to specify the relation between the size and the maximum height of the tree. Not only is the balance criterion simple; the maintenance algorithms are also simple and they can be implemented without keeping any balance information in the nodes. This class of trees, called general balanced trees, is maintained by partial rebuilding. The method of partial rebuilding has been used by Overmars and van Leeuwen ë, 3ë to maintain weight-balanced trees. It can also be used to maintain a modiæed version of æ-balanced trees ë3ë. Partial rebuilding is an attractive method in the sense that it is useful not only for ordinary binary search trees, but also for more complicated data structures, such as multidimensional search trees ë7ë, where other balancing methods do not work. Making a careful analysis we are able to show a lower maintenance cost of general balanced trees than what has been shown for weight-balanced trees. Thus, we improve the method of partial rebuilding in terms of maintenance cost. A preliminary version of this article is published in Proceedings of Workshop on Algorithms and Data Structures, WADS '89, Ottawa ëë. An independent article has also been presented by Galperin and Rivest at the Fourth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA'93 ë13ë. Preliminaries In the following we do not distinguish between nodes and subtrees and by the subtree v we mean the subtree rooted at the node v and by T we mean the entire tree èor the root of the treeè. We deal with binary search trees where each internal node contains one element and each leaf is empty. The number of edges on the path from the root T to the node v is the depth of v. The largest number of edges from a node v to a leaf is the height of v, denoted hèvè. The weight of v equals the number of leaves in v and is denoted. Note that atreecontaining n internal nodes èor elementsè has aweight of n +1. 5

6 Let v H and v L denote the node v's highest and lowest subtrees respectively, ties are broken arbitrarily. As a measure of the shape of the subtree v we use the weight diæerence at v, æèvè, deæned as æèvè = Max è0; jv H j,jv L j,1è è1è As the basic restructuring operation, our algorithms use a procedure for rebuilding a tree to perfect balance, as deæned below. Deænition 1 A binary tree v is perfectly balanced if and only if and æèvè = 0 and v's both subtrees are perfectly balanced trees. In the following we assume that rebuilding a èsub-ètree v takes Oèè time. Examples of linear algorithms for balancing trees can be found in the literature ë10, 11, 13, 17, 5ë. We also assume that updates are performed by adding or removing nodes at the lowest level of the tree. For each nodev, an update below v changes the value of æèvè by at most one. Hence, at least æèvè updates have been made in the subtree v since the last time it was perfectly balanced. 3 Main result The main idea in maintaining a general balanced tree is to let the tree take any shape as long as its height does not exceed dc log jt je for some constant cé1. When this criterion is violated, the height can be decreased by partial rebuilding at a low amortized cost. This is due to the following observation on the shape of an unbalanced tree: Lemma 1 Let T be a binary tree, hèt è é dc log jt je. Let v be the lowest node on èany ofè T 's longest pathèsè such that hèvè é dc log e. Then, æèvè é 1,1=c, 1,1 Proof: Since v is the lowest node satisfying hèvè é dc log e we know that hèv H è dc log jv H je. Hence, èè This gives that dc log e é hèvè =hèv H è+1dc log jv H je +1 dc log e é dc log jv H je +1 jv H j é,1=c è3è è4è From the fact that jv L j =,jv H j we can compute the value of æèvè: æèvè =jv H j,è,jv H jè, 1 =jv H j,,1 é 1,1=c, 1,1: è5è By a straightforward application of Lemma 1 we can maintain a balanced tree eæciently during insertions. 6

7 Theorem 1 If no deletions are made, a binary search tree T with maximum height dc log jt je, c é 1, can be maintained at an amortized cost of Oèlog jt jè per insertion. No balance information is needed in the nodes, only one global integer is needed. Proof: We let the global integer contain the value of jt j. During insertion, we keep track of the depth of the insertion path. Whenever the depth of a new leaf exceeds dc log jt je we back up along the path until we ænd the lowest node v, hèvè é dc log e. We make a partial rebuilding at v. In order to locate the node v, we need to keep track of the heights and weights of the visited nodes as we follow the path upwards. The weights are computed by explicitly counting the nodes in all subtrees along the path. The total cost of this counting is Oèè. After the rebuilding, hèvè = dlog e. This implies that the height of v, and therefore also the height of T, does not exceed the height before the insertion. Hence, if hèt è dc log jt je held before the insertion, it will also hold after. Since the height of an empty tree is zero, the height condition holds by induction. The cost of the rebalancing, including the cost of locating v, is Oèè. According to Lemma 1, æèvè has been changed æèè times since the last time v was involved in a rebuilding. Hence, by reserving a constant amount of extra time each time the weight diæerence is changed at a node, enough time will be saved to cover the cost of rebuilding. Since an update aæects the weight diæerence of Oèlog nè nodes, the amortized cost of insertions will be Oèlog nè. In order to handle deletions eæciently, we make a simple extension to the algorithm above; when enough deletions have been made to cover the cost, we rebuild the entire tree to perfect balance. Theorem Given constants cé1, and b é 0, a balanced tree T with maximum height dc log jt j + be may be maintained without any balance information stored in the nodes, using two global integers, at an amortized cost of Oèlog jt jè per update. Proof: We let the two global integers contain jt j, thenumberofleaves in jt j, and dèt è, the number of deletions made since the last time T was globally rebuilt. Updates are performed in the following way: Insertion: If the depth of the new leaf exceeds dc logèjt j +dèt èèe we back up along the insertion path until we ænd the lowest node v, hèvè é dc log e, where a partial rebuilding is made. Deletion: dèt è increases by one.if dèt è è b=c, 1èjT j we rebuild T to perfect balance and set dèt è=0. A deletion does not increase hèt è. Furthermore, after an insertion we are guaranteed that hèt è dc logèjt j +dètèèe, provided that this relation holds before the insertion. Hence, by induction, hèt è dclogèjt j +dètèèe. Since dèt è é è b=c, 1èjT j, we conclude that hèt è dc logèjt j +dèt èèe l c log è b=c èjt jm = dc log jt j + be: è6è Rebuildings are made on two occasions: when the number of deletions get too large and when the tree gets too high during insertion. The amortized cost for the ærst type of 7

8 M D Q K P T H S X J R V Z U Figure : A GBè1:è-tree which requires rebalancing. rebuilding is constant for each deletion. For the second case we use the same argument as in the proof of Theorem 1. By reserving a constant time each time an update èinsertion or deletionè changes the weight diæerence of a node, we save enough time to cover partial rebuildings. Since the trees maintained in Theorems 1 and are allowed to take any shape as long as their height is low enough, we call them general balanced trees. We use the notation GB-trees or GBècè-trees, where c is the height constant used in the theorems. èthe constant b in Theorem is omitted in this notation.è Example: Figure shows a GBè1:è-tree maintained as in the proof of Theorem. We assume that two deletions have been made since the last global rebuilding and that node U is being inserted. The path to U is too long since hèt è = 6 é d1: logè15 + èe = d1: logèjt j +dètèèe. We have to make a partial rebuilding at one of the nodes on that path. Making a depth-ærst search we ænd that hèqè = 5 é d1: log 10e = d1:logjqje. A partial rebuilding is made at Q and the insertion is completed. The resulting tree is shown in Figure 3. 4 Analysis II: the constant factor Above we proved our main result; a GB-tree can be maintained at Oèlog nè amortized cost per update. In this section, we make a more detailed study. The purpose of this study is to show a better constant factor for GB-trees than what has previously been shown for weight-balanced trees. When analysing the constant factor, by cost we mean the amount of restructuring 8

9 M D T K R X H Q S V Z J P U Figure 3: The tree in Figure after a partial rebuilding. work needed per update. To be more precise, we let the cost of a partial rebuilding equal the number of internal nodes involved. Thus, the cost of a partial rebuilding at node v is,1. Other costs, such as counting sizes of trees, creating new nodes or removing nodes, etc are ignored. The comparison with weight-balanced trees is made in Section 5. Although this was not made in Theorem, the result of Lemma 1 allows us to compute a constant factor, telling an upper bound on the amount of rebalancing work spent per update. We chose to express this work in terms of the number of internal nodes involved in a rebuilding. Thus, the cost of a partial rebuilding at node v is,1. According to Lemma 1, when a partial rebuilding is to be made at node v, we have that æèvè é 1,1=c, 1,1: 1 Thus, the amortized cost of changing the æ-value of a node during an update is. 1,1=c,1 Since an update is made below at most dc log jt je nodes, the amortized cost per update dc log jt je in the entire tree is. 1,1=c,1 The improved analysis is based on the fact that when a node becomes unbalanced there is not only a diæerence in weight between its two subtrees but also a certain imbalance at the lower levels of the tree. In order to measure this imbalance we deæne a function èvè asfollows. èvè = è 0 if v is a leaf æèvè+èv H è+èv L è otherwise, where æèvè is deæned as in the previous section. The imbalance along the longest path from a node v can be expressed using the function æèvè, deæned below. æèvè = è 0 if v is a leaf æèvè+æèv H è otherwise. 9 è7è è8è è9è

10 From the deænitions follows that æèvè æèvè èvè: è10è Below, in Lemma 5, we compute the value of èvè whenv is about to be rebuilt. In order to do that, we ærst show which conæguration gives the lowest possible value of æèvè in Lemmas 3 and 4. We say that a node v has minimal weight if decreasing its weight by one without changing its height would make it out of balance, i.e. if hèvè é dc logè,1èe. Lemma If u has minimal or less weight and u H ju H j,ju L j0. has minimal or larger weight, then Proof: The conditions for the lemma give hèuè é dc logèjuj,1èe and hèu H è dclog ju H je: Hence, dc logèjuj,1èe éhèuè =hèu H è+1dclog ju H je +1: Due to the strict inequality, we can remove the ceilings. Hence, c logèjuj,1è éclog ju H j +1: è11è è1è è13è è14è This gives that ju H j é,1=c èjuj,1è é èjuj,1è= è15è and hence ju H j,ju L j =ju H j,juj é èjuj,1è=,juj é,1: è16è The lemma follows since ju H j,ju L j is an integer. Lemma 3 Let v be a node that is about to be rebuilt during an insertion. Furthermore, assume that is æxed. Then, the smallest possible value of æèvè occurs when each descendant w 6= v along the longest path from v satisæes at least one of the following: æ w has minimal weight; æ jw L j =1. Proof: We prove the lemma by acontradiction. Assume that the smallest value of æèvè occurs only when there exists some nodes on v's longest path which does not satisfy any of the two statements above. Let w be the highest such node and u be the parent of w. That is, w is the same node as u H. The node u will either be v itself, or it may have minimal weight or an empty subtree. Thus, u has minimal or less weight, w has more than minimal weight, and w L é 1. Consider moving a node from w L to u L. Since jw L j é 1, there is a node that can be moved. After the move, w will have minimal or larger weight, while u's weight will be 10

11 the same as before. The overall condition, that a rebuilding is to be made at v, is not aæected by the move. Lemma implies that ju H j,ju L j 0 after the move. This, in turn, implies that ju H j,ju L j was at least before the move. Thus, the move caused æèuè to decrease by at least 1, while æèwè has changed by at most 1. Altogether, the move will not cause æèuè, and hence æèvè, to increase. We can now continue moving nodes until w satisæes the two conditions in the lemma. This gives the contradiction. Lemma 4 For each node v with an empty subtree or minimal weight the following is true: æèvè é 1,1=c, 1,3 Proof: If v has an empty subtree then we are done since æèvè =,1. Otherwise, since v has its smallest possible weight we have è17è hèvè é dc logè,1èe è18è This and the fact that dc log jv H je hèv H è implies that dc log jv H je +1 hèv H è+1=hèvè é dc logè,1èe: è19è Thus, c log jv H j +1éclogè,1è 1=c jv H j é,1 jv H j é,1=c è,1è é,1=c,1 è0è From this follows that æèvè =jv H j,è,jv H jè, 1 =jv H j,,1 é,1=c,1,,1 1,1=c, 1,3: è1è Given the result of Lemma 3 and 4 we can compute the value of èvè whenv is about to be rebuilt. Lemma 5 Let v be a node where a rebuilding is to be made during an insertion. Then, èvè é, 1=c æ è,1è, 3dc log e èè 1=c, 1 11

12 Proof: Let v d be v's dth descendant on the longest path from v. We have that hèv d è+d =hèvè; hèvè é dc log e; and, for d 1, hèv d è dclog jv d je: Combining Eqs. è3è, è4è, and è5è gives è3è è4è è5è dc log jv d je + d hèv d è+d =hèvè é dc log e d=c jv d j é jv d j é,d=c è6è Assume, hypothetically, that v has a minimal value of æ. Combining Lemmas 3 and 4 with Eq. è6è gives that fore every d 1: æèv d è é 1,1=c, 1,d=c,3 è7è For d = 0, the same inequality holds as shown by Lemma 1. Adding the weight diæerences on v's longest path gives èvè æèvè é X dc log e,1 d=0 æèv d è dc log e,1 X 1,1=c, 1 = 1,1=c, 1 æ d=0,d=c, 1,,dc log e=c dc log e,1 X d=0,3dc log e 1,,1=c è, 1=c 1=c, 1 æ 1 1!,,3dc log e =, 1=c 1=c æ è,1è, 3dc log e: è8è, 1 Note that the hypothesis on æèvè is not required. Finally, we are able to give an upper bound on the amount of restructuring work needed to maintain a general balanced tree. In the analysis we assume that the cost of rebuilding a subtree v equals the number of elements in v, which is,1. Theorem 3 Provided that the cost of rebuilding a subtree v is,1 and that cé1 and b é 0, a binary search tree T of height at most dc log jt j + be can be maintained at an amortized restructuring cost of 1=c,1 c log jt j + oèlog jt jè per update., 1=c 3 1

13 Proof: We use the algorithm from Theorem. First, we note that the rebuildings made to compensate for deletions èi.e. when dèt è becomes too largeè only require a constant amortized cost per deletion; the constant depends on the relation between b and c. We ignore the cost for these rebuildings since it is included in the oèlog nè term in the amortized update cost. We associate the tree T with a potential function æèt è. The function æ is chosen such that each update èbefore any rebuildingè increases its value by an amount that is at most 1=c,1 c log jt j + oèlog jt jè. Each rebuilding decreases æèt èby an amount that covers the, 1=c cost of the rebuilding. By showing that the potential is always positive or zero, we prove that the amortized cost of restructuring is at most 1=c,1 c log jt j + oèlog jt jè., 1=c Before we give thepotential function, we would like to make an addition to the deænition of v H and v L from Section. Previously, wehave only used v H and v L in association with nodes that are about to be involved in a partial rebuilding. In order to make our potential argument hold also for nodes that are not about to be involved in a rebuilding, we let the potential function look into the future. For each node v, we let v H be that of v's subtrees which is going to be highest the next time v is involved in a rebuilding, regardless of which subtree is currently the highest. If v will never be involved in any future rebuilding, or if both subtrees will have the same height, we take v H as the right subtree. This deænition implies that we will not be able to compute the exact value of our potential function at a certain moment. However, at each update, we can still compute upper and lower bounds on the change in potential, which is enough for our purposes. In particular, this deænition implies that a partial rebuilding at the node v will not aæect the values of w L and w H for any node w outside the subtree v. The potential æèt è is chosen as where the function èvè is chosen as =c, 1=c æèt è= 1=c, 1 æ èt è+4 1=c, è, 1=c è èt è è9è èvè = 8 é : 0 if v isaleaf æèvèædc log e + èv H è+èv L è otherwise. Note that for a perfectly balanced tree, æèt è = 0. A single update causes the value of dc log e èt è to be changed by at most for each ancestor v of the insertedèdeleted node. By deænition of weight and height we have that hèvè + 1,which implies that è30è dc log e dc logèhèvè+1èe hèvè+1 è31è Thus, the ancestor at height h causes an increase of èt èby at most an update causes the following change in èt è: æèvè = O dc log jt j+b+1e X dc logèh +1èe h=1 log dc log jt je h dc logèh+1èe h+1. Therefore, = oèlog jt jè è3è 13

14 During an update the value of èt èischanged by at most the number of ancestors of the insertedèdeleted node. The number of ancestors is at most dc log jt j + be. Altogether we get an increase of æ by =c, 1=c ææèt è= 1=c, 1 æ æèt è+4, 1=c è, 1=c è æèt è 1=c, 1 c log jt j + oèlog jt jè è33è, 1=c per update. Left to show is that the restructuring cost is covered by the potential function æ. Since the cost of rebuilding trees of constant size can be included in the oèlognè term in the theorem, we may w.l.o.g. assume that 4 é æ 1=c : è34è, 1=c Using the value of æèvè from Lemma 1 in the deænition of èvè, it follows that when v is about to be rebuilt, æèvè ædcælog e èvè è, 1=c é,1 1=c! =, 1=c 1=c ædc æ log e, dc æ log e æ dc æ log e : è35è After a rebuilding at the node v æèvè = 0. Furthermore, for each node w in T which is not part of the subtree v, the values of w H and w L remain unchanged after the rebuilding èdue to the redeænition made aboveè. Hence, Eq. è9è implies a decrease of T 's potential such that =c, 1=c ææèt è=æèvè = 1=c, 1 æ èvè+4, 1=c è, 1=c è èvè: è36è Taking èvè from Lemma 5 and èvè from Eq. 35 we get è! æèvè é 1=c, 1, 1=c, 1=c 1=c, 1 æ è,1è, 3dc log e + 4 è æ =c, 1=c, 1=c è, 1=c è dc log e, 1=c =,1, 1=c, 1, 1=c æ 3dc log e + 1=c, 1, æ 4dc log 4 æ e, 1=c =,1+ 1=c, 1, 1=c, 4 æ 14 =c, 1=c è, 1=c è =c, 1=c è, 1=c è 1 æ dc log e! dc log e æ 1 A ædc log e: è37è

15 Eq. è34è implies that the last term is positive. Hence ææèt è é,1, which implies that the decrease in potential covers the cost of rebuilding at v. The proof follows from the fact that our potential function æ is always nonnegative. 5 A comparison with weight-balanced trees As mentioned in the introduction, the method of partial rebuilding is useful not only for ordinary binary search trees, but also for more complicated data structures, such as multidimensional search trees, where other balancing methods do not work. Previously, the only classes of balanced tree suitable for partial rebuilding have been the weightbalanced trees ë19,, 3ë and a modiæed version of æ-balanced trees ë3ë. Since general balanced trees are also maintained by partial rebuilding, it is natural to compare the maintenance costs. Since æ-balanced trees have the same maintenance cost as weightbalanced trees, we exclude them from our comparison. In order to compare the structures we chose their balance criteria in such a way that the maximum heights of the trees are the same. Given a constant æ, 0 éæé1=, each node v in a weight-balanced tree has to fulæll jv's smallest subtreej æ è38è The maximum height of the tree is & log jt j log 1 1,æ ' : è39è A maximum height of dc log jt je for weight-balanced trees is achieved by choosing æ = 1,,1=c. When anodev becomes out of balance, we have that ëë æèvè è1, æè,1= 1,1=c, 1,1: è40è Thus, if the cost of rebuilding a subtree v is,1, the amortized cost of an update 1 is at most for each ancestor of the insertedèdeleted node. Since an update is 1,1=c,1 made below at most dc log jt je nodes, the amortized cost per update in the entire tree is dc log jt je at most. èa more detailed study of weight-balanced trees maintained by partial 1,1=c,1 rebuilding can be found in the literature ëëè. It should be noted that this bound on maintaining weight-balanced trees is the same as the ærst bound given for GB-trees at the beginning of Section 4. If we compare the cost of GBècè-trees ètheorem 3è with the cost of weight-balanced trees we get = cost of general balanced trees cost of weight-balanced trees 1=c,1 dc log jt je + oèlog jt jè, 1=c dc log jt je 1,1=c,1 15

16 1=c, 1, 1=c æ 1,1=c, 1 =1,,1=c é 1 è41è Thus, the upper bound on the restructuring cost of maintaining balanced trees by partial rebuilding has been reduced by a factor at least. 6 Application to multidimensional search trees In cases when rotations are costly, such as when maintaining k-d trees ë7ë, the method of partial rebuilding oæers a powerful alternative. This has been shown for weight-balanced trees ë19,, 3ë and the same asymptotic bounds can be derived for general balanced trees. Also here, we achieve the advantage of less stored information and a lower constant factor. A detailed study of these matters has been made by Mark Overmars ëë. For the sake of completeness, we just mention that if thecost of rebalancing a subtree v is OèP èèè, the amortized cost of an update will be P ènè O log n n. For example, applied on k-d-trees, we get an amortized update cost of Oèlog nè. 7 Conclusions Introducing general balanced trees, we have shown that there is no need for sophisticated balance criteria in order to maintain balance eæciently. The presented trees use a natural and attractive maintenance strategy; rebalancing is not made until it is really needed. Baer and Schwab ë5ë made an attempt to use a global balance criterion and make restructurings only when this criterion is violated. The amortized cost for their method is æènè per operation. Therefore, they concluded that the best balancing methods are the ones that involve the strictest balance criteria. Here we have shown that, choosing carefully where to make rebuilding, a tree with a global balance criterion can be eæciently maintained. By comparing general balanced trees with weight balanced trees, we have also shown that a restricted balance criterion is not necessarily the best. Another advantage with the general balanced trees is that they can be easily maintained without any extra information stored in the nodes. As shown by Brown ë8, 9ë, the explicitly stored balance information may in some classes of balanced trees be eliminated by coding the information through the location of empty pointers. However, the information is still stored, although implicitly. The splay tree presented by Sleator and Tarjan ë4ë does not require any balance information stored in the nodes. However, the height of a splay tree is not guaranteed to be Oèlog nè. The logarithmic cost for searching in a splay tree is amortized, while we obtain a logarithmic worst-case cost. In summary, the discovery of general balanced trees ælls a gap in the well-studied area of binary search trees, showing that what may be the simplest balance criterion works surprisingly well. We believe that these trees oæer a competitive alternative to other balanced tree structures, both from a theoretical and practical point ofview. 16

17 Finally, an open problem: In this article we have given a better upper bound on the constant factor for GB-trees than what has been shown for weight-balanced trees. We conjecture that the constant factor is indeed better for GB-trees and we leave it as an open problem to prove this. Acknowledgements Many thanks to Amir Ben-Amram for spotting two æaws in the proof of Theorem 3 and for a large number of improving comments during the revising process. The comments by Kerstin Andersson, Svante Carlsson, Johan Hastad, Thomas Ottmann, and Ola Petersson have also improved the presentation of this work. References ë1ë G. M. Adelson-Velskii and E. M. Landis. An algorithm for the organization of information. Dokladi Akademia Nauk SSSR, 146èè:159í16, 196. ëë A. Andersson. Improving partial rebuilding by using simple balance criteria. In Proc. Workshop on Algorithms and Data Structures, Springer Verlag, pages 393í40, ë3ë A. Andersson. Maintaining æ-balanced trees by partial rebuilding. International Journal of Computer Mathmathics, 38:37í48, ë4ë A. Andersson, Ch. Icking, R. Klein, and Th. Ottmann. Binary search trees of almost optimal height. Acta Informatica, 8:165í178, ë5ë J-L. Baer and B. Schwab. A comparison of tree-balancing algorithms. Communications of the ACM, 0è5è:3í330, ë6ë R. Bayer. Symmetric binary B-trees: Data structure and maintenance algorithms. Acta Informatica, 1è4è:90í306, 197. ë7ë J. L. Bentley. Multidimensional binary search trees used for associative searching. Communications of the ACM, 18è9è:509í517, ë8ë M. R. Brown. A storage scheme for height-balanced trees. Information Processing Letters, 7è5è:31í3, ë9ë M. R. Brown. Addendum to ëa storage scheme for height-balanced trees". Information Processing Letters, 8è3è:154í156, ë10ë H. Chang and S. S. Iynegar. Eæcient algorithms to globally balance a binary search tree. Communications of the ACM, 7è7è:695í70, ë11ë A. C. Day. Balancing a binary tree. Computer Journal, 19è4è:360í361, ë1ë C. C. Foster. A generalization of AVL-trees. Communications of the ACM, 16è8è:513í 517,

18 ë13ë I Galperin and R. L. Rivest. Scapegoat trees. In Proceedings of The Fourth Annual ACM-SIAM Symposium on Discrete Algorithms, pages 165í174, ë14ë L. J. Guibas and R. Sedgewick. Adichromatic framework for balanced trees. In Proc. 19th Ann. IEEE Symp. on Foundations of Computer Science, pages 8í1, ë15ë D. E. Knuth. The Art of Computer Programming, Volume 3: Sorting and Searching. Addison-Wesley, Reading, Massachusetts, ISBN X. ë16ë S. R. Kosaraju. Insertion and deletion in one-sided height-balanced trees. Communications of the ACM, 1:6í7, ë17ë W. A. Martin and D. N. Ness. Optimizing binary trees grown with a sorting algorithm. Communications of the ACM, 15èè:88í93, 197. ë18ë H. A. Maurer, Th. Ottmann, and H. W. Six. Implementing dictionaries using binary trees of very small height. Information Processing Letters, 5è1è:11í14, ë19ë K. Mehlhorn. Data Structures and Algorithms 1: Sorting and Searching. Springer- Verlag, ISBN X. ë0ë J. Nievergelt and E. M. Reingold. Binary trees of bounded balance. SIAM Journal on Computing, è1è:33í43, ë1ë H. J. Olivie. A Study of Balanced Binary Trees and Balanced One-Two-Trees. Ph.D. Thesis, Dept of Mathematics, University of Antwerp, ëë M. H. Overmars. The Design of Dynamic Data Structures, volume 156 of Lecture Notes in Computer Science. Springer Verlag, ISBN X. ë3ë M. H. Overmars and J. van Leeuwen. Dynamic multi-dimensional data structures based on quad- and k-d trees. Acta Informatica, 17:67í85, 198. ë4ë D. D. Sleator and R. E. Tarjan. Self-adjusting binary search trees. Journal of the ACM, 3è3è:65í686, ë5ë Q. F. Stout and B. L. Warren. Tree rebalancing in optimal time and space. Communications of the ACM, 9è9è:90í908,

The Complexity of Constructing Evolutionary Trees Using Experiments

The Complexity of Constructing Evolutionary Trees Using Experiments The Complexity of Constructing Evolutionary Trees Using Experiments Gerth Stlting Brodal 1,, Rolf Fagerberg 1,, Christian N. S. Pedersen 1,, and Anna Östlin2, 1 BRICS, Department of Computer Science, University

More information

search trees. It is therefore important to obtain as full an understanding of the issue as possible. Additionally, there are practical applications fo

search trees. It is therefore important to obtain as full an understanding of the issue as possible. Additionally, there are practical applications fo AVL Trees with Relaxed Balance Kim S. Larsen y University of Southern Denmar, Odense z Abstract The idea of relaxed balance is to uncouple the rebalancing in search trees from the updating in order to

More information

Lecture 2 14 February, 2007

Lecture 2 14 February, 2007 6.851: Advanced Data Structures Spring 2007 Prof. Erik Demaine Lecture 2 14 February, 2007 Scribes: Christopher Moh, Aditya Rathnam 1 Overview In the last lecture we covered linked lists and some results

More information

Search Trees. Chapter 10. CSE 2011 Prof. J. Elder Last Updated: :52 AM

Search Trees. Chapter 10. CSE 2011 Prof. J. Elder Last Updated: :52 AM Search Trees Chapter 1 < 6 2 > 1 4 = 8 9-1 - Outline Ø Binary Search Trees Ø AVL Trees Ø Splay Trees - 2 - Outline Ø Binary Search Trees Ø AVL Trees Ø Splay Trees - 3 - Binary Search Trees Ø A binary search

More information

Search Trees. EECS 2011 Prof. J. Elder Last Updated: 24 March 2015

Search Trees. EECS 2011 Prof. J. Elder Last Updated: 24 March 2015 Search Trees < 6 2 > 1 4 = 8 9-1 - Outline Ø Binary Search Trees Ø AVL Trees Ø Splay Trees - 2 - Learning Outcomes Ø From this lecture, you should be able to: q Define the properties of a binary search

More information

AVL Trees. Manolis Koubarakis. Data Structures and Programming Techniques

AVL Trees. Manolis Koubarakis. Data Structures and Programming Techniques AVL Trees Manolis Koubarakis 1 AVL Trees We will now introduce AVL trees that have the property that they are kept almost balanced but not completely balanced. In this way we have O(log n) search time

More information

In the previous chapters we have presented synthesis methods for optimal H 2 and

In the previous chapters we have presented synthesis methods for optimal H 2 and Chapter 8 Robust performance problems In the previous chapters we have presented synthesis methods for optimal H 2 and H1 control problems, and studied the robust stabilization problem with respect to

More information

A General Lower Bound on the I/O-Complexity of Comparison-based Algorithms

A General Lower Bound on the I/O-Complexity of Comparison-based Algorithms A General Lower ound on the I/O-Complexity of Comparison-based Algorithms Lars Arge Mikael Knudsen Kirsten Larsent Aarhus University, Computer Science Department Ny Munkegade, DK-8000 Aarhus C. August

More information

Optimal Color Range Reporting in One Dimension

Optimal Color Range Reporting in One Dimension Optimal Color Range Reporting in One Dimension Yakov Nekrich 1 and Jeffrey Scott Vitter 1 The University of Kansas. yakov.nekrich@googlemail.com, jsv@ku.edu Abstract. Color (or categorical) range reporting

More information

A Tight Lower Bound for Top-Down Skew Heaps

A Tight Lower Bound for Top-Down Skew Heaps A Tight Lower Bound for Top-Down Skew Heaps Berry Schoenmakers January, 1997 Abstract Previously, it was shown in a paper by Kaldewaij and Schoenmakers that for topdown skew heaps the amortized number

More information

Lecture 17: Trees and Merge Sort 10:00 AM, Oct 15, 2018

Lecture 17: Trees and Merge Sort 10:00 AM, Oct 15, 2018 CS17 Integrated Introduction to Computer Science Klein Contents Lecture 17: Trees and Merge Sort 10:00 AM, Oct 15, 2018 1 Tree definitions 1 2 Analysis of mergesort using a binary tree 1 3 Analysis of

More information

Deænition 1 A set S is ænite if there exists a number N such that the number of elements in S èdenoted jsjè is less than N. If no such N exists, then

Deænition 1 A set S is ænite if there exists a number N such that the number of elements in S èdenoted jsjè is less than N. If no such N exists, then Morphology of Proof An introduction to rigorous proof techniques Craig Silverstein September 26, 1998 1 Methodology of Proof an example Deep down, all theorems are of the form if A then B. They may be

More information

Each internal node v with d(v) children stores d 1 keys. k i 1 < key in i-th sub-tree k i, where we use k 0 = and k d =.

Each internal node v with d(v) children stores d 1 keys. k i 1 < key in i-th sub-tree k i, where we use k 0 = and k d =. 7.5 (a, b)-trees 7.5 (a, b)-trees Definition For b a an (a, b)-tree is a search tree with the following properties. all leaves have the same distance to the root. every internal non-root vertex v has at

More information

Search Trees and Stirling Numbers

Search Trees and Stirling Numbers ELS~rIF~R An Intemational Joumal Available online at: www.sciencedirect.com computers &.,~.c=c~o,.=.. mathematics with applications Computers and Mathematics with Applications 48 (2004) 747-754 www.elsevier.com/locat

More information

16. Binary Search Trees. [Ottman/Widmayer, Kap. 5.1, Cormen et al, Kap ]

16. Binary Search Trees. [Ottman/Widmayer, Kap. 5.1, Cormen et al, Kap ] 418 16. Binary Search Trees [Ottman/Widmayer, Kap. 5.1, Cormen et al, Kap. 12.1-12.3] 419 Dictionary implementation Hashing: implementation of dictionaries with expected very fast access times. Disadvantages

More information

Splay Trees. CMSC 420: Lecture 8

Splay Trees. CMSC 420: Lecture 8 Splay Trees CMSC 420: Lecture 8 AVL Trees Nice Features: - Worst case O(log n) performance guarantee - Fairly simple to implement Problem though: - Have to maintain etra balance factor storage at each

More information

Transforming Hierarchical Trees on Metric Spaces

Transforming Hierarchical Trees on Metric Spaces CCCG 016, Vancouver, British Columbia, August 3 5, 016 Transforming Hierarchical Trees on Metric Spaces Mahmoodreza Jahanseir Donald R. Sheehy Abstract We show how a simple hierarchical tree called a cover

More information

Expected heights in heaps. Jeannette M. de Graaf and Walter A. Kosters

Expected heights in heaps. Jeannette M. de Graaf and Walter A. Kosters Expected heights in heaps Jeannette M. de Graaf and Walter A. Kosters Department of Mathematics and Computer Science Leiden University P.O. Box 951 300 RA Leiden The Netherlands Abstract In this paper

More information

16. Binary Search Trees. [Ottman/Widmayer, Kap. 5.1, Cormen et al, Kap ]

16. Binary Search Trees. [Ottman/Widmayer, Kap. 5.1, Cormen et al, Kap ] 423 16. Binary Search Trees [Ottman/Widmayer, Kap. 5.1, Cormen et al, Kap. 12.1-12.3] Dictionary implementation 424 Hashing: implementation of dictionaries with expected very fast access times. Disadvantages

More information

9 Union Find. 9 Union Find. List Implementation. 9 Union Find. Union Find Data Structure P: Maintains a partition of disjoint sets over elements.

9 Union Find. 9 Union Find. List Implementation. 9 Union Find. Union Find Data Structure P: Maintains a partition of disjoint sets over elements. Union Find Data Structure P: Maintains a partition of disjoint sets over elements. P. makeset(x): Given an element x, adds x to the data-structure and creates a singleton set that contains only this element.

More information

Sorting n Objects with a k-sorter. Richard Beigel. Dept. of Computer Science. P.O. Box 2158, Yale Station. Yale University. New Haven, CT

Sorting n Objects with a k-sorter. Richard Beigel. Dept. of Computer Science. P.O. Box 2158, Yale Station. Yale University. New Haven, CT Sorting n Objects with a -Sorter Richard Beigel Dept. of Computer Science P.O. Box 258, Yale Station Yale University New Haven, CT 06520-258 John Gill Department of Electrical Engineering Stanford University

More information

MA008/MIIZ01 Design and Analysis of Algorithms Lecture Notes 3

MA008/MIIZ01 Design and Analysis of Algorithms Lecture Notes 3 MA008 p.1/37 MA008/MIIZ01 Design and Analysis of Algorithms Lecture Notes 3 Dr. Markus Hagenbuchner markus@uow.edu.au. MA008 p.2/37 Exercise 1 (from LN 2) Asymptotic Notation When constants appear in exponents

More information

Entropy-Preserving Cuttings and Space-Efficient Planar Point Location

Entropy-Preserving Cuttings and Space-Efficient Planar Point Location Appeared in ODA 2001, pp. 256-261. Entropy-Preserving Cuttings and pace-efficient Planar Point Location unil Arya Theocharis Malamatos David M. Mount Abstract Point location is the problem of preprocessing

More information

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Dynamic Programming II Date: 10/12/17

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Dynamic Programming II Date: 10/12/17 601.433/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Dynamic Programming II Date: 10/12/17 12.1 Introduction Today we re going to do a couple more examples of dynamic programming. While

More information

Problem. Problem Given a dictionary and a word. Which page (if any) contains the given word? 3 / 26

Problem. Problem Given a dictionary and a word. Which page (if any) contains the given word? 3 / 26 Binary Search Introduction Problem Problem Given a dictionary and a word. Which page (if any) contains the given word? 3 / 26 Strategy 1: Random Search Randomly select a page until the page containing

More information

SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION

SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION CHAPTER 5 SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION Copyright Cengage Learning. All rights reserved. SECTION 5.4 Strong Mathematical Induction and the Well-Ordering Principle for the Integers Copyright

More information

Proof methods and greedy algorithms

Proof methods and greedy algorithms Proof methods and greedy algorithms Magnus Lie Hetland Lecture notes, May 5th 2008 1 Introduction This lecture in some ways covers two separate topics: (1) how to prove algorithms correct, in general,

More information

Lower Bounds for Dynamic Connectivity (2004; Pǎtraşcu, Demaine)

Lower Bounds for Dynamic Connectivity (2004; Pǎtraşcu, Demaine) Lower Bounds for Dynamic Connectivity (2004; Pǎtraşcu, Demaine) Mihai Pǎtraşcu, MIT, web.mit.edu/ mip/www/ Index terms: partial-sums problem, prefix sums, dynamic lower bounds Synonyms: dynamic trees 1

More information

Notes on Logarithmic Lower Bounds in the Cell Probe Model

Notes on Logarithmic Lower Bounds in the Cell Probe Model Notes on Logarithmic Lower Bounds in the Cell Probe Model Kevin Zatloukal November 10, 2010 1 Overview Paper is by Mihai Pâtraşcu and Erik Demaine. Both were at MIT at the time. (Mihai is now at AT&T Labs.)

More information

AVL-Trees for Localized Search

AVL-Trees for Localized Search INFORMATION AND CONTROL 67, 173-194 (1985) AVL-Trees for Localized Search ATHANASIOS K. TSAKALIDIS Fachbereich 10, Angewandte Mathematik und Informatik, Universit~t des Saarlandes, D-6600 Saarbri~cken,

More information

Algorithms for pattern involvement in permutations

Algorithms for pattern involvement in permutations Algorithms for pattern involvement in permutations M. H. Albert Department of Computer Science R. E. L. Aldred Department of Mathematics and Statistics M. D. Atkinson Department of Computer Science D.

More information

A Robust APTAS for the Classical Bin Packing Problem

A Robust APTAS for the Classical Bin Packing Problem A Robust APTAS for the Classical Bin Packing Problem Leah Epstein 1 and Asaf Levin 2 1 Department of Mathematics, University of Haifa, 31905 Haifa, Israel. Email: lea@math.haifa.ac.il 2 Department of Statistics,

More information

Dynamic Ordered Sets with Exponential Search Trees

Dynamic Ordered Sets with Exponential Search Trees Dynamic Ordered Sets with Exponential Search Trees Arne Andersson Computing Science Department Information Technology, Uppsala University Box 311, SE - 751 05 Uppsala, Sweden arnea@csd.uu.se http://www.csd.uu.se/

More information

Algorithmica. Biased Skip Lists 1. Amitabha Bagchi, 2 Adam L. Buchsbaum, 3 and Michael T. Goodrich 2

Algorithmica. Biased Skip Lists 1. Amitabha Bagchi, 2 Adam L. Buchsbaum, 3 and Michael T. Goodrich 2 Algorithmica 2005 42: 31 48 DOI: 10.1007/s00453-004-1138-6 Algorithmica 2005 Springer Science+Business Media, Inc. Biased Skip Lists 1 Amitabha Bagchi, 2 Adam L. Buchsbaum, 3 and Michael T. Goodrich 2

More information

The total current injected in the system must be zero, therefore the sum of vector entries B j j is zero, è1;:::1èb j j =: Excluding j by means of è1è

The total current injected in the system must be zero, therefore the sum of vector entries B j j is zero, è1;:::1èb j j =: Excluding j by means of è1è 1 Optimization of networks 1.1 Description of electrical networks Consider an electrical network of N nodes n 1 ;:::n N and M links that join them together. Each linkl pq = l k joints the notes numbered

More information

Functional Data Structures

Functional Data Structures Functional Data Structures with Isabelle/HOL Tobias Nipkow Fakultät für Informatik Technische Universität München 2017-2-3 1 Part II Functional Data Structures 2 Chapter 1 Binary Trees 3 1 Binary Trees

More information

Data Structures and Algorithms " Search Trees!!

Data Structures and Algorithms  Search Trees!! Data Structures and Algorithms " Search Trees!! Outline" Binary Search Trees! AVL Trees! (2,4) Trees! 2 Binary Search Trees! "! < 6 2 > 1 4 = 8 9 Ordered Dictionaries" Keys are assumed to come from a total

More information

On the Exponent of the All Pairs Shortest Path Problem

On the Exponent of the All Pairs Shortest Path Problem On the Exponent of the All Pairs Shortest Path Problem Noga Alon Department of Mathematics Sackler Faculty of Exact Sciences Tel Aviv University Zvi Galil Department of Computer Science Sackler Faculty

More information

1. Introduction Bottom-Up-Heapsort is a variant of the classical Heapsort algorithm due to Williams ([Wi64]) and Floyd ([F64]) and was rst presented i

1. Introduction Bottom-Up-Heapsort is a variant of the classical Heapsort algorithm due to Williams ([Wi64]) and Floyd ([F64]) and was rst presented i A Tight Lower Bound for the Worst Case of Bottom-Up-Heapsort 1 by Rudolf Fleischer 2 Keywords : heapsort, bottom-up-heapsort, tight lower bound ABSTRACT Bottom-Up-Heapsort is a variant of Heapsort. Its

More information

Algorithms and Data Structures 2016 Week 5 solutions (Tues 9th - Fri 12th February)

Algorithms and Data Structures 2016 Week 5 solutions (Tues 9th - Fri 12th February) Algorithms and Data Structures 016 Week 5 solutions (Tues 9th - Fri 1th February) 1. Draw the decision tree (under the assumption of all-distinct inputs) Quicksort for n = 3. answer: (of course you should

More information

1 Approximate Quantiles and Summaries

1 Approximate Quantiles and Summaries CS 598CSC: Algorithms for Big Data Lecture date: Sept 25, 2014 Instructor: Chandra Chekuri Scribe: Chandra Chekuri Suppose we have a stream a 1, a 2,..., a n of objects from an ordered universe. For simplicity

More information

CMSC 451: Lecture 7 Greedy Algorithms for Scheduling Tuesday, Sep 19, 2017

CMSC 451: Lecture 7 Greedy Algorithms for Scheduling Tuesday, Sep 19, 2017 CMSC CMSC : Lecture Greedy Algorithms for Scheduling Tuesday, Sep 9, 0 Reading: Sects.. and. of KT. (Not covered in DPV.) Interval Scheduling: We continue our discussion of greedy algorithms with a number

More information

Polynomial Time Algorithms for Minimum Energy Scheduling

Polynomial Time Algorithms for Minimum Energy Scheduling Polynomial Time Algorithms for Minimum Energy Scheduling Philippe Baptiste 1, Marek Chrobak 2, and Christoph Dürr 1 1 CNRS, LIX UMR 7161, Ecole Polytechnique 91128 Palaiseau, France. Supported by CNRS/NSF

More information

Ordered Dictionary & Binary Search Tree

Ordered Dictionary & Binary Search Tree Ordered Dictionary & Binary Search Tree Finite map from keys to values, assuming keys are comparable (). insert(k, v) lookup(k) aka find: the associated value if any delete(k) (Ordered set: No values;

More information

A lower bound for scheduling of unit jobs with immediate decision on parallel machines

A lower bound for scheduling of unit jobs with immediate decision on parallel machines A lower bound for scheduling of unit jobs with immediate decision on parallel machines Tomáš Ebenlendr Jiří Sgall Abstract Consider scheduling of unit jobs with release times and deadlines on m identical

More information

CS 161: Design and Analysis of Algorithms

CS 161: Design and Analysis of Algorithms CS 161: Design and Analysis of Algorithms Greedy Algorithms 3: Minimum Spanning Trees/Scheduling Disjoint Sets, continued Analysis of Kruskal s Algorithm Interval Scheduling Disjoint Sets, Continued Each

More information

in (n log 2 (n + 1)) time by performing about 3n log 2 n key comparisons and 4 3 n log 4 2 n element moves (cf. [24]) in the worst case. Soon after th

in (n log 2 (n + 1)) time by performing about 3n log 2 n key comparisons and 4 3 n log 4 2 n element moves (cf. [24]) in the worst case. Soon after th The Ultimate Heapsort Jyrki Katajainen Department of Computer Science, University of Copenhagen Universitetsparken 1, DK-2100 Copenhagen East, Denmark Abstract. A variant of Heapsort named Ultimate Heapsort

More information

8 Priority Queues. 8 Priority Queues. Prim s Minimum Spanning Tree Algorithm. Dijkstra s Shortest Path Algorithm

8 Priority Queues. 8 Priority Queues. Prim s Minimum Spanning Tree Algorithm. Dijkstra s Shortest Path Algorithm 8 Priority Queues 8 Priority Queues A Priority Queue S is a dynamic set data structure that supports the following operations: S. build(x 1,..., x n ): Creates a data-structure that contains just the elements

More information

Notes on induction proofs and recursive definitions

Notes on induction proofs and recursive definitions Notes on induction proofs and recursive definitions James Aspnes December 13, 2010 1 Simple induction Most of the proof techniques we ve talked about so far are only really useful for proving a property

More information

Research Article On Counting and Embedding a Subclass of Height-Balanced Trees

Research Article On Counting and Embedding a Subclass of Height-Balanced Trees Modelling and Simulation in Engineering, Article ID 748941, 5 pages http://dxdoiorg/101155/2014/748941 Research Article On Counting and Embedding a Subclass of Height-Balanced Trees Indhumathi Raman School

More information

University of California, Berkeley. ABSTRACT

University of California, Berkeley. ABSTRACT Jagged Bite Problem NP-Complete Construction Kris Hildrum and Megan Thomas Computer Science Division University of California, Berkeley fhildrum,mctg@cs.berkeley.edu ABSTRACT Ahyper-rectangle is commonly

More information

Lecture 1 : Data Compression and Entropy

Lecture 1 : Data Compression and Entropy CPS290: Algorithmic Foundations of Data Science January 8, 207 Lecture : Data Compression and Entropy Lecturer: Kamesh Munagala Scribe: Kamesh Munagala In this lecture, we will study a simple model for

More information

CSE 421 Greedy: Huffman Codes

CSE 421 Greedy: Huffman Codes CSE 421 Greedy: Huffman Codes Yin Tat Lee 1 Compression Example 100k file, 6 letter alphabet: File Size: ASCII, 8 bits/char: 800kbits 2 3 > 6; 3 bits/char: 300kbits better: 2.52 bits/char 74%*2 +26%*4:

More information

Proof Techniques (Review of Math 271)

Proof Techniques (Review of Math 271) Chapter 2 Proof Techniques (Review of Math 271) 2.1 Overview This chapter reviews proof techniques that were probably introduced in Math 271 and that may also have been used in a different way in Phil

More information

Y fli log (1/fli)+ ce log (1/at) is the entropy of the frequency distribution. This

Y fli log (1/fli)+ ce log (1/at) is the entropy of the frequency distribution. This SIAM J. COMPUT. Vol. 6, No. 2, June 1977 A BEST POSSIBLE BOUND FOR THE WEIGHTED PATH LENGTH OF BINARY SEARCH TREES* KURT MEHLHORN Abstract. The weighted path length of optimum binary search trees is bounded

More information

A Unified Access Bound on Comparison-Based Dynamic Dictionaries 1

A Unified Access Bound on Comparison-Based Dynamic Dictionaries 1 A Unified Access Bound on Comparison-Based Dynamic Dictionaries 1 Mihai Bădoiu MIT Computer Science and Artificial Intelligence Laboratory, 32 Vassar Street, Cambridge, MA 02139, USA Richard Cole 2 Computer

More information

past balancing schemes require maintenance of balance info at all times, are aggresive use work of searches to pay for work of rebalancing

past balancing schemes require maintenance of balance info at all times, are aggresive use work of searches to pay for work of rebalancing 1 Splay Trees Sleator and Tarjan, Self Adjusting Binary Search Trees JACM 32(3) 1985 The claim planning ahead. But matches previous idea of being lazy, letting potential build up, using it to pay for expensive

More information

W 1 æw 2 G + 0 e? u K y Figure 5.1: Control of uncertain system. For MIMO systems, the normbounded uncertainty description is generalized by assuming

W 1 æw 2 G + 0 e? u K y Figure 5.1: Control of uncertain system. For MIMO systems, the normbounded uncertainty description is generalized by assuming Chapter 5 Robust stability and the H1 norm An important application of the H1 control problem arises when studying robustness against model uncertainties. It turns out that the condition that a control

More information

Biased Skip Lists.

Biased Skip Lists. Biased Skip Lists Amitabha Bagchi, Adam L. Buchsbaum 2, and Michael T. Goodrich 3 Dept. of Computer Science, Johns Hopkins Univ., Baltimore, MD 228, bagchi@cs.jhu.edu 2 AT&T Labs, Shannon Laboratory, 80

More information

Outline. Computer Science 331. Cost of Binary Search Tree Operations. Bounds on Height: Worst- and Average-Case

Outline. Computer Science 331. Cost of Binary Search Tree Operations. Bounds on Height: Worst- and Average-Case Outline Computer Science Average Case Analysis: Binary Search Trees Mike Jacobson Department of Computer Science University of Calgary Lecture #7 Motivation and Objective Definition 4 Mike Jacobson (University

More information

arxiv: v1 [math.co] 13 May 2016

arxiv: v1 [math.co] 13 May 2016 GENERALISED RAMSEY NUMBERS FOR TWO SETS OF CYCLES MIKAEL HANSSON arxiv:1605.04301v1 [math.co] 13 May 2016 Abstract. We determine several generalised Ramsey numbers for two sets Γ 1 and Γ 2 of cycles, in

More information

2-INF-237 Vybrané partie z dátových štruktúr 2-INF-237 Selected Topics in Data Structures

2-INF-237 Vybrané partie z dátových štruktúr 2-INF-237 Selected Topics in Data Structures 2-INF-237 Vybrané partie z dátových štruktúr 2-INF-237 Selected Topics in Data Structures Instructor: Broňa Brejová E-mail: brejova@fmph.uniba.sk Office: M163 Course webpage: http://compbio.fmph.uniba.sk/vyuka/vpds/

More information

Analysis of Algorithms - Using Asymptotic Bounds -

Analysis of Algorithms - Using Asymptotic Bounds - Analysis of Algorithms - Using Asymptotic Bounds - Andreas Ermedahl MRTC (Mälardalens Real-Time Research Center) andreas.ermedahl@mdh.se Autumn 004 Rehersal: Asymptotic bounds Gives running time bounds

More information

Algorithm for exact evaluation of bivariate two-sample Kolmogorov-Smirnov statistics in O(nlogn) time.

Algorithm for exact evaluation of bivariate two-sample Kolmogorov-Smirnov statistics in O(nlogn) time. Algorithm for exact evaluation of bivariate two-sample Kolmogorov-Smirnov statistics in O(nlogn) time. Krystian Zawistowski January 3, 2019 Abstract We propose an O(nlogn) algorithm for evaluation of bivariate

More information

Outline for Today. Static Optimality. Splay Trees. Properties of Splay Trees. Dynamic Optimality (ITA) Balanced BSTs aren't necessarily optimal!

Outline for Today. Static Optimality. Splay Trees. Properties of Splay Trees. Dynamic Optimality (ITA) Balanced BSTs aren't necessarily optimal! Splay Trees Outline for Today Static Optimality alanced STs aren't necessarily optimal! Splay Trees self-adjusting binary search tree. Properties of Splay Trees Why is splaying worthwhile? ynamic Optimality

More information

Chapter 1. Comparison-Sorting and Selecting in. Totally Monotone Matrices. totally monotone matrices can be found in [4], [5], [9],

Chapter 1. Comparison-Sorting and Selecting in. Totally Monotone Matrices. totally monotone matrices can be found in [4], [5], [9], Chapter 1 Comparison-Sorting and Selecting in Totally Monotone Matrices Noga Alon Yossi Azar y Abstract An mn matrix A is called totally monotone if for all i 1 < i 2 and j 1 < j 2, A[i 1; j 1] > A[i 1;

More information

Fall 2017 November 10, Written Homework 5

Fall 2017 November 10, Written Homework 5 CS1800 Discrete Structures Profs. Aslam, Gold, & Pavlu Fall 2017 November 10, 2017 Assigned: Mon Nov 13 2017 Due: Wed Nov 29 2017 Instructions: Written Homework 5 The assignment has to be uploaded to blackboard

More information

Data Compression Techniques

Data Compression Techniques Data Compression Techniques Part 2: Text Compression Lecture 5: Context-Based Compression Juha Kärkkäinen 14.11.2017 1 / 19 Text Compression We will now look at techniques for text compression. These techniques

More information

E D I C T The internal extent formula for compacted tries

E D I C T The internal extent formula for compacted tries E D C T The internal extent formula for compacted tries Paolo Boldi Sebastiano Vigna Università degli Studi di Milano, taly Abstract t is well known [Knu97, pages 399 4] that in a binary tree the external

More information

On Adaptive Integer Sorting

On Adaptive Integer Sorting On Adaptive Integer Sorting Anna Pagh 1, Rasmus Pagh 1, and Mikkel Thorup 2 1 IT University of Copenhagen, Rued Langgaardsvej 7, 2300 København S, Denmark {annao, pagh}@itu.dk 2 AT&T Labs Research, Shannon

More information

The null-pointers in a binary search tree are replaced by pointers to special null-vertices, that do not carry any object-data

The null-pointers in a binary search tree are replaced by pointers to special null-vertices, that do not carry any object-data Definition 1 A red black tree is a balanced binary search tree in which each internal node has two children. Each internal node has a color, such that 1. The root is black. 2. All leaf nodes are black.

More information

A Probabilistic Algorithm for -SAT Based on Limited Local Search and Restart

A Probabilistic Algorithm for -SAT Based on Limited Local Search and Restart A Probabilistic Algorithm for -SAT Based on Limited Local Search and Restart Uwe Schöning Universität Ulm, Abteilung Theoretische Informatik James-Franck-Ring, D-89069 Ulm, Germany e-mail: schoenin@informatik.uni-ulm.de

More information

The Union of Probabilistic Boxes: Maintaining the Volume

The Union of Probabilistic Boxes: Maintaining the Volume The Union of Probabilistic Boxes: Maintaining the Volume Hakan Yıldız 1, Luca Foschini 1, John Hershberger 2, and Subhash Suri 1 1 University of California, Santa Barbara, USA 2 Mentor Graphics Corporation,

More information

Data selection. Lower complexity bound for sorting

Data selection. Lower complexity bound for sorting Data selection. Lower complexity bound for sorting Lecturer: Georgy Gimel farb COMPSCI 220 Algorithms and Data Structures 1 / 12 1 Data selection: Quickselect 2 Lower complexity bound for sorting 3 The

More information

Hashing. Martin Babka. January 12, 2011

Hashing. Martin Babka. January 12, 2011 Hashing Martin Babka January 12, 2011 Hashing Hashing, Universal hashing, Perfect hashing Input data is uniformly distributed. A dynamic set is stored. Universal hashing Randomised algorithm uniform choice

More information

Dictionary: an abstract data type

Dictionary: an abstract data type 2-3 Trees 1 Dictionary: an abstract data type A container that maps keys to values Dictionary operations Insert Search Delete Several possible implementations Balanced search trees Hash tables 2 2-3 trees

More information

N/4 + N/2 + N = 2N 2.

N/4 + N/2 + N = 2N 2. CS61B Summer 2006 Instructor: Erin Korber Lecture 24, 7 Aug. 1 Amortized Analysis For some of the data structures we ve discussed (namely hash tables and splay trees), it was claimed that the average time

More information

On improving matchings in trees, via bounded-length augmentations 1

On improving matchings in trees, via bounded-length augmentations 1 On improving matchings in trees, via bounded-length augmentations 1 Julien Bensmail a, Valentin Garnero a, Nicolas Nisse a a Université Côte d Azur, CNRS, Inria, I3S, France Abstract Due to a classical

More information

Randomization in Algorithms and Data Structures

Randomization in Algorithms and Data Structures Randomization in Algorithms and Data Structures 3 lectures (Tuesdays 14:15-16:00) May 1: Gerth Stølting Brodal May 8: Kasper Green Larsen May 15: Peyman Afshani For each lecture one handin exercise deadline

More information

New Minimal Weight Representations for Left-to-Right Window Methods

New Minimal Weight Representations for Left-to-Right Window Methods New Minimal Weight Representations for Left-to-Right Window Methods James A. Muir 1 and Douglas R. Stinson 2 1 Department of Combinatorics and Optimization 2 School of Computer Science University of Waterloo

More information

Reverse mathematics of some topics from algorithmic graph theory

Reverse mathematics of some topics from algorithmic graph theory F U N D A M E N T A MATHEMATICAE 157 (1998) Reverse mathematics of some topics from algorithmic graph theory by Peter G. C l o t e (Chestnut Hill, Mass.) and Jeffry L. H i r s t (Boone, N.C.) Abstract.

More information

Data Structures 1 NTIN066

Data Structures 1 NTIN066 Data Structures 1 NTIN066 Jirka Fink Department of Theoretical Computer Science and Mathematical Logic Faculty of Mathematics and Physics Charles University in Prague Winter semester 2017/18 Last change

More information

hal , version 1-27 Mar 2014

hal , version 1-27 Mar 2014 Author manuscript, published in "2nd Multidisciplinary International Conference on Scheduling : Theory and Applications (MISTA 2005), New York, NY. : United States (2005)" 2 More formally, we denote by

More information

Standard forms for writing numbers

Standard forms for writing numbers Standard forms for writing numbers In order to relate the abstract mathematical descriptions of familiar number systems to the everyday descriptions of numbers by decimal expansions and similar means,

More information

ADVANCED CALCULUS - MTH433 LECTURE 4 - FINITE AND INFINITE SETS

ADVANCED CALCULUS - MTH433 LECTURE 4 - FINITE AND INFINITE SETS ADVANCED CALCULUS - MTH433 LECTURE 4 - FINITE AND INFINITE SETS 1. Cardinal number of a set The cardinal number (or simply cardinal) of a set is a generalization of the concept of the number of elements

More information

A New Invariance Property of Lyapunov Characteristic Directions S. Bharadwaj and K.D. Mease Mechanical and Aerospace Engineering University of Califor

A New Invariance Property of Lyapunov Characteristic Directions S. Bharadwaj and K.D. Mease Mechanical and Aerospace Engineering University of Califor A New Invariance Property of Lyapunov Characteristic Directions S. Bharadwaj and K.D. Mease Mechanical and Aerospace Engineering University of California, Irvine, California, 92697-3975 Email: sanjay@eng.uci.edu,

More information

Lecture 6: September 22

Lecture 6: September 22 CS294 Markov Chain Monte Carlo: Foundations & Applications Fall 2009 Lecture 6: September 22 Lecturer: Prof. Alistair Sinclair Scribes: Alistair Sinclair Disclaimer: These notes have not been subjected

More information

An Optimization-Based Heuristic for the Split Delivery Vehicle Routing Problem

An Optimization-Based Heuristic for the Split Delivery Vehicle Routing Problem An Optimization-Based Heuristic for the Split Delivery Vehicle Routing Problem Claudia Archetti (1) Martin W.P. Savelsbergh (2) M. Grazia Speranza (1) (1) University of Brescia, Department of Quantitative

More information

Best Increments for the Average Case of Shellsort

Best Increments for the Average Case of Shellsort Best Increments for the Average Case of Shellsort Marcin Ciura Department of Computer Science, Silesian Institute of Technology, Akademicka 16, PL 44 100 Gliwice, Poland Abstract. This paper presents the

More information

Lecture 7: More Arithmetic and Fun With Primes

Lecture 7: More Arithmetic and Fun With Primes IAS/PCMI Summer Session 2000 Clay Mathematics Undergraduate Program Advanced Course on Computational Complexity Lecture 7: More Arithmetic and Fun With Primes David Mix Barrington and Alexis Maciel July

More information

Chapter 5 Data Structures Algorithm Theory WS 2017/18 Fabian Kuhn

Chapter 5 Data Structures Algorithm Theory WS 2017/18 Fabian Kuhn Chapter 5 Data Structures Algorithm Theory WS 2017/18 Fabian Kuhn Priority Queue / Heap Stores (key,data) pairs (like dictionary) But, different set of operations: Initialize-Heap: creates new empty heap

More information

A Linear Time Algorithm for Ordered Partition

A Linear Time Algorithm for Ordered Partition A Linear Time Algorithm for Ordered Partition Yijie Han School of Computing and Engineering University of Missouri at Kansas City Kansas City, Missouri 64 hanyij@umkc.edu Abstract. We present a deterministic

More information

LECTURE Review. In this lecture we shall study the errors and stability properties for numerical solutions of initial value.

LECTURE Review. In this lecture we shall study the errors and stability properties for numerical solutions of initial value. LECTURE 24 Error Analysis for Multi-step Methods 1. Review In this lecture we shall study the errors and stability properties for numerical solutions of initial value problems of the form è24.1è dx = fèt;

More information

Postorder Preimages. arxiv: v3 [math.co] 2 Feb Colin Defant 1. 1 Introduction

Postorder Preimages. arxiv: v3 [math.co] 2 Feb Colin Defant 1. 1 Introduction Discrete Mathematics and Theoretical Computer Science DMTCS vol. 19:1, 2017, #3 Postorder Preimages arxiv:1604.01723v3 [math.co] 2 Feb 2017 1 University of Florida Colin Defant 1 received 7 th Apr. 2016,

More information

k-protected VERTICES IN BINARY SEARCH TREES

k-protected VERTICES IN BINARY SEARCH TREES k-protected VERTICES IN BINARY SEARCH TREES MIKLÓS BÓNA Abstract. We show that for every k, the probability that a randomly selected vertex of a random binary search tree on n nodes is at distance k from

More information

CS Data Structures and Algorithm Analysis

CS Data Structures and Algorithm Analysis CS 483 - Data Structures and Algorithm Analysis Lecture VII: Chapter 6, part 2 R. Paul Wiegand George Mason University, Department of Computer Science March 22, 2006 Outline 1 Balanced Trees 2 Heaps &

More information

On the mean connected induced subgraph order of cographs

On the mean connected induced subgraph order of cographs AUSTRALASIAN JOURNAL OF COMBINATORICS Volume 71(1) (018), Pages 161 183 On the mean connected induced subgraph order of cographs Matthew E Kroeker Lucas Mol Ortrud R Oellermann University of Winnipeg Winnipeg,

More information

PEANO AXIOMS FOR THE NATURAL NUMBERS AND PROOFS BY INDUCTION. The Peano axioms

PEANO AXIOMS FOR THE NATURAL NUMBERS AND PROOFS BY INDUCTION. The Peano axioms PEANO AXIOMS FOR THE NATURAL NUMBERS AND PROOFS BY INDUCTION The Peano axioms The following are the axioms for the natural numbers N. You might think of N as the set of integers {0, 1, 2,...}, but it turns

More information

CSC 5170: Theory of Computational Complexity Lecture 4 The Chinese University of Hong Kong 1 February 2010

CSC 5170: Theory of Computational Complexity Lecture 4 The Chinese University of Hong Kong 1 February 2010 CSC 5170: Theory of Computational Complexity Lecture 4 The Chinese University of Hong Kong 1 February 2010 Computational complexity studies the amount of resources necessary to perform given computations.

More information

Chapter 5. Number Theory. 5.1 Base b representations

Chapter 5. Number Theory. 5.1 Base b representations Chapter 5 Number Theory The material in this chapter offers a small glimpse of why a lot of facts that you ve probably nown and used for a long time are true. It also offers some exposure to generalization,

More information