time using O( n log n ) processors on the EREW PRAM. Thus, our algorithm improves on the previous results, either in time complexity or in the model o

Size: px
Start display at page:

Download "time using O( n log n ) processors on the EREW PRAM. Thus, our algorithm improves on the previous results, either in time complexity or in the model o"

Transcription

1 Reconstructing a Binary Tree from its Traversals in Doubly-Logarithmic CREW Time Stephan Olariu Michael Overstreet Department of Computer Science, Old Dominion University, Norfolk, VA Zhaofang Wen y Department of Computer Science, University of Minnesota, Duluth, MN55812 Abstract We consider the following problem. For a binary tree T = (V; E) where V = f1; 2; :::; ng, given its inorder traversal and either its preorder or its postorder traversal, reconstruct the binary tree. We present a new parallel algorithm for this problem. Our algorithm requires O(n) space. The main idea of our algorithm is to reduce the reconstruction process to merging two sorted sequences. With the best parallel merging algorithms, our algorithm can be implemented n in O(log log n) time using O( log log n ) processors on the CREW PRAM (or in O(log n) time using O( n log n ) processors on the EREW PRAM). Our result provides one more example of a fundamental problem which can be solved by optimal parallel algorithms in O(log log n) time on the CREW PRAM. 1 Introduction We consider the problem of reconstructing a binary tree T = (V; E) with vertices f1; 2; :::; ng given its inorder traversal and either its preorder or its postorder traversal. It is well-known that a binary tree can be reconstructed from its inorder traversal along with either its preorder or its postorder traversals [8]. Recently, sequential solutions to this classical problem have reported in [1, 4]. Especially, the algorithm in [1] requires O(n) time and space. Parallel solutions to this problem can be found in [3, 10]. In particular, the algorithm in [10] runs in O(log n) time using O(n) processors on the CREW PRAM; and the solution in [3] takes in O(log log n) time using O( n log log n ) processors on the CRCW PRAM. Most recently, parallel algorithms running in O(log n) time with O( n log n ) processors on the EREW PRAM were also reported in [7, 5] 1. In this paper, we present a new parallel algorithm for this problem. Our algorithm requires O(n) space. The main idea of our algorithm is to reduce the reconstruction process to merging two sorted sequences. With the best results for parallel merging, our algorithm can be implemented in O(log log n) time using O( n log log n ) processors on the CREW PRAM or in O(log n) This author was supported in part by the National Science Foundation under grant CCR y Part of the work was done when the author was with Dept. of Computer Science, Old Dominion University 1 We learned about these algorithms after submission of this paper 1

2 time using O( n log n ) processors on the EREW PRAM. Thus, our algorithm improves on the previous results, either in time complexity or in the model of computation. As pointed out in [3], optimal parallel algorithms that run in O(log log n) time usually need to be implemented on the CRCW PRAM. For example, any optimal O(log log n) time parallel algorithm for the All Nearest Smaller Values (ANSV) problem [3] needs the CRCW PRAM. It is worth noting that in [3] the solution for the ANSV problem is used to solve the binary tree reconstruction problem in O(log log n) time, with O( n log log n ) processors on the CRCW PRAM. The only known doubly logarithmic optimal CREW algorithm is Kruskal's parallel merging algorithm [9], which runs in O(log log n) time using O( n log log n ) processors on the CREW PRAM [9]. The main contribution of this paper is to provide another example of designing doubly logarithmic time parallel algorithm on the CREW PRAM. 2 Preliminaries Many methods can be used to generate traversals for a binary tree. Here, we are interested in one of them, known as the Euler Tour technique. This powerful technique was proposed by Tarjan and Vishkin [11] for designing ecient parallel algorithms on trees. Specically, this technique reduces the computation of various kinds of information about the tree structure to the computation on a linked list. To make this paper self-contained, the Euler tour technique for binary trees is described next. The Euler tour technique: Let T be a binary tree. Every node v of T is split into three copies v 1, v 2, and v 3, all having the same node label as v. For each of the resulting nodes, we dene a next eld as follows: If v has no left child then v 1 :next = v 2. If v has no right child then v 2 :next = v 3. If w is the left child of v then v 1 :next = w 1, and w 3 :next = v 2. If w is the right child of v then v 2 :next = w 1 and w 3 :next = v 3. What results is a linked list, called an Euler path, which starts at root 1 and ends at root 3 and traverses each edge of T exactly once in each direction. Letting T be a binary tree tree with left subtree T 1 and right subtree T 2. The Euler path (T ) of T can be expressed as root 1 (T 1 )root 2 (T 2 )root 3. When no confusion is possible, we let the Euler path denote the sequence of node labels contained in the corresponding linked list. Obviously, the Euler path of a binary tree contains 2

3 1 AA A A A 2 3 B B B B B B C C C 7 8 Euler path: Preorder-inorder Euler path: Preorder traversal: Inorder traversal: Figure 1: a binary tree and its various (Euler) paths and traversals three copies of each node label in the tree. An interesting property of the Euler path of a binary tree T is that keeping only the rst copy of each label results in a preorder traversal of T; keeping only the second copy of each label gives an inorder traversal of T ; and keeping only the third copy of each label yields a postorder traversal of T [11]. For convenience, we dene a preorder-inorder Euler path to be a sequence of labels obtained by deleting the third copy of each label in an Euler path. Similarly, we can dene an inorderpostorder Euler path as a sequence of labels obtained by deleting the rst copy of each label in an Euler path. It is well-known that a binary tree can be reconstructed from its inorder traversal along with either its preorder or postorder traversal [8]. It follows that a binary tree is completely determined by its preorder-inorder Euler path or its inorder-postorder Euler path. For example, Figure 1 features a binary tree along with the associate Euler path, preorderinorder Euler path, preorder traversal, and inorder traversal. Lemma 1 A sequence of labels b 1, b 2,...,b 2n represents a preorder-inorder Euler path (respectively, the inorder-postorder Euler path) of an n-node binary tree T if and only if, the following two conditions hold: (1) there are exactly two copies of each label in the sequence; and (2) there exist no integers i; j; k; m with 1 i < j < k < m 2n such that b i = b k and b j = b m. Proof We prove the statement for the case of a preorder-inorder Euler path (the case of an 3

4 inorder-postorder Euler path follows by a mirror argument). Let (T ) denote the preorder-inorder Euler path of a tree T. Note that the preorderinorder Euler path of a tree with left subtree T 1 and right subtree T 2 can be expressed as root 1 (T 1 )root 2 (T 2 ). Thus, the \only if" part of the lemma follows by an obvious inductive argument. The \if" part will be proved by induction on n. When n = 1 the lemma is obviously true. Assume the lemma true for 1 < n < k. When n = k, let b t be the second copy of b 1, i.e. b t = b 1. By condition (2) and the induction hypothesis, b 2,..., b t?1 and b t+1,..., b 2n can both be seen as a preorder-inorder Euler paths. Let T 1 and T 2 be the binary trees determined by b 2,..., b t?1 and b t+1,..., b 2n, respectively. The tree rooted at b 1 with left subtree T 1 and right subtree T 2 is the binary tree determined by b 1,..., b 2n. 2 Intuitively, Lemma 1 states that any preorder-inorder Euler path containing distinct labels u and v must be of the form \:::u:::v:::v:::u:::" or \:::u:::u:::v:::v:::"; it is impossible for a preorderinorder Euler path to be of the form \:::u:::v:::u:::v:::", which we refer to as overlapping of labels u and v. Let b 1, b 2,..., b 2n be a preorder-inorder Euler path with 2n labels. For any pair of duplicate labels b i and b j (1 i < j n), we call b i the rst copy of its duplicate label and b j the second copy of its duplicate label. The following corollary of Lemma 1 will be used in the Appendix. Corollary 1 Let c 1, c 2,..., c n and d 1, d 2,..., d n be the preorder and inorder traversals of a binary tree, respectively. There do not exist integers i 1, i 2, j 1, j 2, k 1, k 2 such that (1 i 1 < j 1 < k 1 n) and (1 k 2 < i 2 < j 2 n), and (c i1 = d i2 ) ^ (c j1 = d j2 ) ^ (c k1 = d k2 ). Proof. (by contradiction) Assume there exist integers i 1, i 2, j 1, j 2, k 1, k 2 such that (1 i 1 < j 1 < k 1 n) and (1 k 2 < i 2 < j 2 n), and (c i1 = d i2 ) ^ (c j1 = d j2 ) ^ (c k1 = d k2 ). Then, in the corresponding preorder-inorder Euler path, d k2 is the second copy of the node label c k1, and we can nd :::c i1 :::c j1 :::c k1 :::d k2 :::d i2 :::d j2 ::: contradicting condition (2) of Lemma 1 (due to :::c i1 :::c j1 ::::::d i2 :::d j2 :::). 2 Intuitively, Corollary 1 states that if the preorder traversal of a binary tree is of the form \:::u:::v:::w:::", then the inorder traversal can never be of form \:::w:::u:::v:::"; where u, v, and 4

5 w are three distinct node labels. 3 The Algorithm To reconstruct a binary tree from its preorder and inorder traversals, our algorithm has two steps. The rst step is to construct the preorder-inorder Euler path of the binary tree determined by the traversals. Once the preorder-inorder Euler path is available, it is straightforward to reconstruct the corresponding binary tree. Hence, we would like to give rst the following procedure to implement the second step: Procedure EulerPath-to-Tree; Input: b 1, b 2,...,b 2n, a preorder-inorder Euler path in which every label remembers the position of its duplicate. Output: A binary tree with root r and set of nodes S = f1; :::; ng; begin r b 1 ; for each label b i (1 i 2n) do if (b i is the rst copy of its duplicate) then if (b i+1 is the rst copy of its duplicate label) then leftchild(b i ) b i+1 ; else fcomment: b i is the second copy of its duplicateg if (b i+1 is the rst copy of its duplicate label) then rightchild(b i ) b i+1 ; end. Lemma 2 Given a preorder-inorder Euler path with 2n labels in which each label remembers the position of its duplicate, procedure EulerPath-to-Tree correctly reconstructs the corresponding binary tree in O(1) time using O(n) processors on the EREW PRAM. Proof. The correctness of the algorithm follows directly from the proof of Lemma 1. It is obvious that the procedure above can be implemented in O(1) time using O(n) processors on the EREW PRAM. 2 5

6 We now turn to the rst step of our tree reconstruction algorithm, that is, the construction of the preorder-inorder Euler path from the traversals. The main idea of this step is suggested by Lemma 1, which tells that overlapping of labels is impossible in a preorder-inorder Euler path. In addition, we know that keeping only the rst copy of each label in a preorder-inorder Euler path gives the preorder traversal of the binary tree, and that keeping only the second copy of each label in an preorder-inorder Euler path yields the inorder traversal of the binary tree. The idea here is to \merge" the preorder and inorder traversals into a sequence that satises the above properties. To give the reader some intuition about this idea, we show that this \merging" process can actually be carried out with the help of a stack, as in the following procedure. ProcedureTraversals-to-EulerPath; Input:c 1, c 2,...,c n, the preorder traversal of a binary tree, and d 1, d 2,...,d n, the inorder traversal of the same binary tree. Output: b 1, b 2,...,b 2n, the preorder-inorder Euler path of the binary determined by the traversals. begin Stack ; j k 1; for i 1 to 2n do if (d k matches the label on the top of Stack) then b i d k ; pop Stack; and d k remembers each other's position in the sequence b 1, b 2,...,b 2n ; k k + 1; else b i c j ; push c j onto Stack; j j + 1; return(b 1, b 2,...,b 2n ); end. 6

7 Lemma 3 Given the preorder and the inorder traversals of an n-node binary tree T, Procedure Traversals-to-EulerPath correctly construct in O(n) time the preorder-inorder Euler path of T, such that every label remembers the position of its duplicate in the path. Proof. We prove the correctness of the procedure by induction on n. When n = 1, the correctness is obvious. Assume the procedure correct for 1 < n < k. Consider the case when n = k. Without loss of generality, assume d q = c 1. By the denitions of the inorder and preorder traversals, c 1 is the root of T, and the left subtree of T has preorder traversal c 2,..., c q and inorder traversal d 1,..., d q?1 ; the right subtree of T has preorder traversal c q+1,..., c k and inorder traversal d q+1,..., d k. By the induction hypothesis, consuming subsequences c 2,..., c q and d 1,..., d q?1 the procedure computes b 2, b 3,..., b 2q?2 as the preorder-inorder Euler path of the left subtree, with c 1 left on the top of Stack. After matching d q with the top of Stack (i.e. c 1 ), the algorithm proceeds to computes b 2q, b 2q+1,..., b 2k as the preorder-inorder Euler path of the right subtree by consuming subsequences c q+1,..., c k and d q+1,..., d k. From the discussion above, we see that the output sequence b 1, b 2,...,b 2n satises both conditions of Lemma 1. Thus, the output sequence represents the preorder-inorder path of some tree. Furthermore, keeping only the rst copies of the labels in b 1,...,b 2n results in c 1,...,c n, while keeping only the the second copies of the labels gives d 1,...,d n. It follows that b 1, b 2,...,b 2n is the preorder-inorder Euler path of T. According to the way the Stack is used in the algorithm, we ensure that each label in the output sequence remembers the position of its duplicate. The procedure takes O(n) sequential time, since each iteration of the for loop runs in O(1) time. 2 Combining Lemma 2 and Lemma 3, we have the following result. Theorem 1 An n-node binary tree can be reconstructed from its preorder and inorder traversal in O(n) time with O(n) extra space. 2 Although it is easy to implement procedure Traversals-to-EulerPath sequentially, it is not obvious how the procedure can be implemented in parallel. In the following, we will show that the idea behind the Stack being used in the procedure can lead to the denition of a linear order. With this linear order, both the preorder and the inorder traversals are sorted sequences; 7

8 and the construction of the preorder-inorder path can be done by merging these two sorted sequences according to the linear order. Let c 1 ; c 2 ; :::c n and d 1 ; d 2 ; :::; d n be the preorder and inorder traversals of T. For simplicity, we assume that c 1 ; c 2 ; :::c n is 1; 2; :::; n. (the case where c 1 ; c 2 ; :::c n is a permutation of 1, 2,..., n can be reduced to this case easily). Construct two sequences of triples: a sequence (1; j 1 ; c 1 ); (1; j 2 ; c 2 ); :::; (1; j n ; c n ) such that d ji = c i ; (i = 1; 2; :::; n) (i.e. j i is the position of c i in sequence d 1 ; d 2 ; :::; d n ), and a sequence (2; 1; d 1 ); (2; 2; d 2 ); :::; (2; n; d n ). Denote Q = f(1; j 1 ; c 1 ); (1; j 2 ; c 2 ); :::; (1; j n ; c n ); (2; 1; d 1 ); (2; 2; d 2 ); :::; (2; n; d n )g. Dene a binary relation on Q as follows: for arbitrary triples (; ; ) and ( 0 ; 0 ; 0 ) in Q we have: Rule 1. (( = 1) ^ ( 0 = 1))! (((; ; ) ( 0 ; 0 ; 0 )) $ ( < 0 )); Rule 2. (( = 2) ^ ( 0 = 2))! (((; ; ) ( 0 ; 0 ; 0 )) $ ( < 0 )); Rule 3. (( = 1) ^ ( 0 = 2))! (((; ; ) ( 0 ; 0 ; 0 )) $ (( 0 ) _ ( 0 ))) The motivation behind Rules 1{2 is the fact that keeping only the rst (second) copies of the labels in the preorder-inorder Euler path gives the preorder (inorder) traversal of the binary tree. Therefore, when combining the traversals the original relative order between labels from the same traversal should be maintained. (For the case of Rule 1, notice the assumption that c 1 ; c 2 ; :::c n is 1; 2; :::; n.) The motivation for Rule 3 is the following: For any c i and d j, their relative order in the merged sequence should be determined in a way consistent with the fact that overlapping of labels is not allowed in the preorder-inorder Euler path (see Lemma 1), and that the copy of a label from the preorder traversal should always come before the copy of the same label from the inorder traversal. It is easy to conrm that the binary relation is total on Q. In addition, it turns out that it is also transitive (refer to the Appendix for the proof), and so is a linear order on Q. Rules 1{2 guarantee that is consistent with both sequences (1; j 1 ; c 1 ), (1; j 2 ; c 2 ),..., (1; j n ; c n ) and (2; 1; d 1 ), (2; 2; d 2 ),..., (2; n; d n ). By merging these two sequences according to we obtain a sorted sequence of 2n triples, ( 1 ; 1 ; 1 ), ( 2 ; 2 ; 2 ),..., ( 2n ; 2n ; 2n ). We claim that 1, 2,..., 2n is the preorder-inorder Euler path of the tree determined by the traversals. By Lemma 1, the correctness of the claim relies on the following facts: 8

9 (a) There are exactly two copies of each label in 1, 2,..., 2n ; the rst copy is from the preorder traversal and the second copy is from the inorder traversal. (b) There do not exist 1 i < j < k < m 2n such that i = k and j = m (c) Deleting the second copies of the duplicate labels in 1, 2,..., 2n results in c 1 ; c 2 ; :::c n ; and deleting the rst copies of the duplicate labels in 1, 2,..., 2n gives d 1 ; d 2 ; :::d n. Fact (a) follows from Rule 3 and the construction of the set Q. By the denition of both sequences (1; j 1 ; c 1 ), (1; j 2 ; c 2 ),..., (1; j n ; c n ) and (2; 1; d 1 ), (2; 2; d 2 ),..., (2; n; d n ) are already sorted, so fact (c) is also true. The proof of fact (b) is given below: Proof of (b). (by contradiction) (1)( i = k ) ^ ( j = m ) [Assumption] where 1 i < j < k < m 2n (2)( i ; i ; i ) ( j ; j ; j ) ( k ; k ; k ) [by 1 i < j < k < m 2n ( m ; m ; m ) in (1)] (3)( i = 1) ^ ( j = 1) ^ ( k = 2) ^ ( m = 2) [by (1), (2), Rule 3 and the construction of the triples] (4)( i = k ) ^ ( j = m ) [ by (1) and the construction of the triples ] (5)( j k ) _ ( j k ) [by ( j = 1) ^ ( k = 2) in (3), ( j ; j ; j ) ( k ; k ; k ) in (2) and Rule 3] (6)( m k ) _ ( m k ) [replace j ; j in (5) with m ; m respectively, by (1) and (4)] (7)( k < m ) [by ( k ; k ; k ) ( m ; m ; m ) in (2), ( k = 2) ^ ( m = 2) in (3) and Rule 2] (8)( m k ) [by (6) and (7)] (9)( i < j ) [by ( i ; i ; i ) ( j ; j ; j ) in (2), ( i = 1) ^ ( j = 1) in (3) and Rule 1] (10)( k < m ) [by (1) and (9) ] (11)Contradiction [(8) and (10)] 2 Up to this point, we have successfully reduced computing the preorder-inorder path to parallel merging. We now discuss the complexity of this reduction. First, we consider the complexity to construct Q. For this purpose, let us see how to construct from the given traversals, sequences (1; j 1 ; c 1 ), (1; j 2 ; c 2 ),..., (1; j n ; c n ) and (2; 1; d 1 ), (2; 2; d 2 ),..., (2; n; d n ) such that c i = d ji (i = 1; 2; :::; n). We note that this can be done easily with an auxiliary array A[1::n]. Since c 1 ; c 2 ; :::; c n is 1; 2; :::; n, and d 1 ; d 2 ; :::; d n is a permutation of 1; 2; :::; n, we can compute the entries of A[1::n] as follow: A[d i ] = i (1; 2; :::; n) in O(1) time on an EREW PRAM with n processors. To determine the subscript j i satisfying c i = d ji (1; 2; :::; n), we simply take j i = A[c i ] 9

10 (1; 2; :::; n). This again can be computed in O(1) time on an EREW PRAM with n processors. Consequently, Q can be constructed in O(1) time using n processors on an EREW PRAM. Next, we consider the complexity to merge (1; j 1 ; c 1 ), (1; j 2 ; c 2 ),..., (1; j n ; c n ) and (2; 1; d 1 ), (2; 2; d 2 ),..., (2; n; d n ) according. Optimal parallel algorithms are proposed in [2, 6, 9]. With their results, we have, Theorem 2 A binary tree T = (V; E) where V = f1; 2; :::; ng, can be reconstructed from its preorder and inorder traversals in O(log log n) time using O( n log log n ) processors on the CREW PRAM, or in O(log n) time using O( n log n ) processors on the EREW PRAM, using O(n) extra space, 2 In case the inorder traversal and the postorder traversal is given, the binary tree can be reconstructed similarly. 4 Conclusion We have shown how to reconstruct a binary tree from its inorder traversal along with either its preorder traversal or its postorder traversal by reducing the problem to parallel merging. With the best known results for parallel merging, our reconstruction algorithm can be implemented in O(log log n) time using O( n log log n ) processors on the CREW PRAM (or in O(log n) time using O( n log n ) processors on the EREW PRAM). We have thus found one more example in the class of problems that can be solved in doubly logarithmic time using optimal number of processors on the CREW PRAM. Acknowledgement: The authors would like to thank two anonymous referees for a very thorough review that resulted in a much better presentation. References [1] A. Anderson and S. Carlsson. Construction of a tree from its traversals in optimal time and space. Information Processing Letters, 34:21{25, [2] R. J. Anderson, E. W. Mayr, and M. K. Warmuth. Parallel approximation algorithms for bin backing. Information and Computation, 82:262{277, October

11 [3] O. Berkman, D. Breslauer, Z. Galil, B. Schieber, and U. Vishkin. Highly parallelizable problems. In Proceedings of the Annual IEEE Symposium on Foundation of Computer Science, pages 309{319, [4] G. H. Chen, M. S. Yu, and L. T. Liu. Two algorithms for constructing a binary tree from its traversals. Information Processing Letters, 28:297{299, [5] N. Gabrani and P. Shankar. A note on the reconstruction of a binary tree from its traversals. Information Processing Letters, 42:117{119, [6] T. Hagerup and C. Rub. Optimal merging and sorting on the EREW PRAM. Information Processing Letters, 33:181{185, [7] V. Kamakoti and C. Pandu Rangan. An optimal algorithm for reconstructing a binary tree. Information Processing Letters, 42:113{115, [8] D. E. Knuth. The Art of Computer Programming, Vol. 1, Fundamental Algorithms. Second Edition, Addison-Wesley, Reading, Mass., [9] C. P. Kruskal. Searching, merging, and sorting in parallel computation. IEEE Transactions on Computers, 32:924{946, [10] F. Springsteel and I. Stojmenovic. Parallel general prex computations with geometric, algebraic and other applications. In Proceedings of the International Conference on on Fundamentals of Computation Theory, Szeged, Hungary, August, 1989, Springer-Verlag, pages 424{433, [11] R. E. Tarjan and U. Vishkin. An ecient parallel biconnectivity algorithm. SIAM J. Comput., pages 862{874,

12 Appendix The purpose of this appendix is to show that the binary relation dened in Section 3 is a linear order on the set Q. For completeness, we repeat the denition of before we give the proof. Let c 1 ; c 2 ; :::; c n and d 1 ; d 2 ; :::; d n be the preorder and inorder traversals of a binary tree T, where c 1 ; c 2 ; :::c n is 1; 2; :::; n. Construct two sequences of triples: a sequence (1; j 1 ; c 1 ), (1; j 2 ; c 2 ),..., (1; j n ; c n ) such that d ji = c i, (i = 1; 2; :::; n) (i.e. j i is the position of c i in sequence d 1, d 2,..., d n, and a sequence (2; 1; d 1 ), (2; 2; d 2 ),..., (2; n; d n ). Write Q = f(1; j 1 ; c 1 ); (1; j 2 ; c 2 ); :::; (1; j n ; c n ); (2; 1; d 1 ); (2; 2; d 2 ); :::; (2; n; d n )g and dene a binary relation on Q as follows: for arbitrary triples (; ; ) and ( 0 ; 0 ; 0 ) in Q we have: Rule 1. (( = 1) ^ ( 0 = 1))! (((; ; ) ( 0 ; 0 ; 0 )) $ ( < 0 )); Rule 2. (( = 2) ^ ( 0 = 2))! (((; ; ) ( 0 ; 0 ; 0 )) $ ( < 0 )); Rule 3. (( = 1) ^ ( 0 = 2))! (((; ; ) ( 0 ; 0 ; 0 )) $ (( 0 ) _ ( 0 ))) Quite often, we shall nd it convenient to use the following equivalent formulation of Rule 3. Rule 3. (( = 2) ^ ( 0 = 1))! (((; ; ) ( 0 ; 0 ; 0 )) $ (( < 0 ) ^ ( < 0 ))) We note that Rules 1{3 above imply that the binary relation is total on Q. We propose to show that, in fact, is a linear order. For this purpose, we only need to justify that is transitive. We shall present our arguments in the form of a case-by-case analysis. Let (; ; ), ( 0 ; 0 ; 0 ) and ("; "; ") be arbitrary triples in Q satisfying: (; ; ) ( 0 ; 0 ; 0 ) and ( 0 ; 0 ; 0 ) ("; "; ") We need prove that (; ; ) ("; "; "). Our proof procceds in a case by case fashion. Case 1. = " Subcase 1.1 = 0 = " = 1. By Rule 1 and the assumption of this subcase, we have < 0 and 0 < " and therefore < ". The conclusion follows by Rule 1. Subcase 1.2 = " = 1 and 0 = 2 By Rule 3, (a) ( 0 ) W ( 0 ) By Rule 3, again, 12

13 (b) ( 0 < ") V ( 0 < ") If < " then conclusion follows immediately from Rule 1. Therefore, we assume (c) " < Note that (a), (b) and (c) combined imply that ( 0 < " < ) V ( < 0 < ") which is contradicting Corollary 1. (The contradiction is derived as follows: Because = 00 = 1 and 0 = 2, and 00 are from c 1, c 2,..., c n ; and 0 is from d 1, d 2,..., d n. Assume = c i, 00 = c k, 0 = d j 0 Further assume c i = d i 0, c j = d j 0, and c k = d k 0 We have (c j < c k < c i ) ^ (i 0 < j 0 < k 0 ). Since c 1, c 2,..., c n is 1, 2,..., n, we have (j < k < i) ^ (i 0 < j 0 < k 0 ) and c i = d i 0, c j = d j 0, and c k = d k 0, which contradict Corollary 1. ) Subcase 1.3 = 0 = " = 2 By Rule 2, we have < 0 and 0 < " and therefore < ". The conclusion follows by Rule 2. Subcase 1.4 = 2, 0 = 1 and " = 2 By Rule 3, (d) ( < 0 ) V ( < 0 ) By Rule 3, again, (e) ( 0 ") W ( 0 ") If ( < ") then conclusion follows instantly from Rule 2. We may assume, therefore, (f) (" < ) By now, (d), (e) and (f) combined imply that ( < 0 < ") V (" < < 0 ) which contradicts Corollary 1. Case 2. 6= " Subcase 2.1 = 0 = 1 and " = 2. By Rule 1, (g) ( < 0 ) By Rule 3, (h) ( 0 ") V ( 0 ") 13

14 Note that if ( ") W ( ") then by Rule 3, we have (; ; ) ("; "; "). Therefore, we may assume that (i) (" < ) V (" ) But now, (g), (h) and (i) combined imply (" < < 0 ) V ( 0 < " < ) which contradicts Corollary 1. Subcase 2.2 = 1 and 0 = " = 2. By Rule 3, (j) ( 0 ) W ( ") By Rule 2, (k) ( 0 < ") Note that if ( ") W ( ") then the conclusion follows by Rule 3, Therefore, we may assume that (l) (" < ) V (" < ) But now, (j), (k) and (l) combined imply (" < < 0 ) V ( 0 < " < ) which contradicts Corollary 1. Subcase 2.3 = 2 and 0 = " = 1. By Rule 3, (m) ( < 0 ) V ( < 0 ) By Rule 1, (n) ( 0 < ") Note that if ( ") V ( ") then the conclusion follows by Rule 3, Therefore, we may assume that (o) (" < ) V (" < ) But now, (m), (n) and (o) combined imply ( < 0 < ") V (" < < ") which contradicts Corollary 1. Subcase 2.4 = 0 = 2 and " = 1. By Rule 2, (p) ( < 0 ) By Rule 3, 14

15 (q) ( 0 ") V ( 0 < ") Note that if ( < ") then (p) and (q) combined give (; ; ) ("; "; ") by Rule 3. Thus, we may assume (" < ). But now (p) and (q) imply ( 0 < " < ) V ( < 0 < ) which contradicts Corollary

Fast Parallel String Prex-Matching. Dany Breslauer. April 6, Abstract. n log m -processor CRCW-PRAM algorithm for the

Fast Parallel String Prex-Matching. Dany Breslauer. April 6, Abstract. n log m -processor CRCW-PRAM algorithm for the Fast Parallel String Prex-Matching Dany Breslauer April 6, 1995 Abstract An O(log logm) time n log m -processor CRCW-PRAM algorithm for the string prex-matching problem over general alphabets is presented.

More information

[25] T. Watanabe, An ecient way for edge-connectivity augmentation, Tech. Rep. ACT-

[25] T. Watanabe, An ecient way for edge-connectivity augmentation, Tech. Rep. ACT- [25] T. Watanabe, An ecient way for edge-connectivity augmentation, Tech. Rep. ACT- 76-UILU-ENG-87-2221, Coordinated Science lab., University of Illinois, Urbana, IL, 1987. [26] T. Watanabe and A. Nakamura,

More information

We assume uniform hashing (UH):

We assume uniform hashing (UH): We assume uniform hashing (UH): the probe sequence of each key is equally likely to be any of the! permutations of 0,1,, 1 UH generalizes the notion of SUH that produces not just a single number, but a

More information

Optimal Parallel Randomized Renaming

Optimal Parallel Randomized Renaming Optimal Parallel Randomized Renaming Martin Farach S. Muthukrishnan September 11, 1995 Abstract We consider the Renaming Problem, a basic processing step in string algorithms, for which we give a simultaneously

More information

An Optimal Parallel Algorithm for Merging using Multiselection

An Optimal Parallel Algorithm for Merging using Multiselection An Optimal Parallel Algorithm for Merging using Multiselection Narsingh Deo Amit Jain Muralidhar Medidi Department of Computer Science, University of Central Florida, Orlando, FL 32816 Keywords: selection,

More information

A Fast Algorithm for Optimal Alignment between Similar Ordered Trees

A Fast Algorithm for Optimal Alignment between Similar Ordered Trees Fundamenta Informaticae 56 (2003) 105 120 105 IOS Press A Fast Algorithm for Optimal Alignment between Similar Ordered Trees Jesper Jansson Department of Computer Science Lund University, Box 118 SE-221

More information

Theorem 2.9: nearest addition algorithm

Theorem 2.9: nearest addition algorithm There are severe limits on our ability to compute near-optimal tours It is NP-complete to decide whether a given undirected =(,)has a Hamiltonian cycle An approximation algorithm for the TSP can be used

More information

A new NC Algorithm for Perfect Matching in Bipartite Cubic Graphs

A new NC Algorithm for Perfect Matching in Bipartite Cubic Graphs A new NC Algorithm for Perfect Matching in Bipartite Cubic Graphs Roded Sharan Avi Wigderson Institute of Computer Science, Hebrew University of Jerusalem, Israel. E-mail: roded@math.tau.ac.il, avi@cs.huji.ac.il

More information

THE EULER TOUR TECHNIQUE: EVALUATION OF TREE FUNCTIONS

THE EULER TOUR TECHNIQUE: EVALUATION OF TREE FUNCTIONS PARALLEL AND DISTRIBUTED ALGORITHMS BY DEBDEEP MUKHOPADHYAY AND ABHISHEK SOMANI http://cse.iitkgp.ac.in/~debdeep/courses_iitkgp/palgo/index.htm THE EULER TOUR TECHNIQUE: EVALUATION OF TREE FUNCTIONS 2

More information

Heap-on-Top Priority Queues. March Abstract. We introduce the heap-on-top (hot) priority queue data structure that combines the

Heap-on-Top Priority Queues. March Abstract. We introduce the heap-on-top (hot) priority queue data structure that combines the Heap-on-Top Priority Queues Boris V. Cherkassky Central Economics and Mathematics Institute Krasikova St. 32 117418, Moscow, Russia cher@cemi.msk.su Andrew V. Goldberg NEC Research Institute 4 Independence

More information

Parallel Recognition of Series-Parallel Graphs

Parallel Recognition of Series-Parallel Graphs Parallel Recognition of Series-Parallel Graphs David Eppstein Department of Information and Computer Science University of California, Irvine, CA 92717 October 4, 1990 Abstract Recently, He and Yesha gave

More information

THE EULER TOUR TECHNIQUE: EVALUATION OF TREE FUNCTIONS

THE EULER TOUR TECHNIQUE: EVALUATION OF TREE FUNCTIONS PARALLEL AND DISTRIBUTED ALGORITHMS BY DEBDEEP MUKHOPADHYAY AND ABHISHEK SOMANI http://cse.iitkgp.ac.in/~debdeep/courses_iitkgp/palgo/index.htm THE EULER TOUR TECHNIQUE: EVALUATION OF TREE FUNCTIONS 2

More information

II (Sorting and) Order Statistics

II (Sorting and) Order Statistics II (Sorting and) Order Statistics Heapsort Quicksort Sorting in Linear Time Medians and Order Statistics 8 Sorting in Linear Time The sorting algorithms introduced thus far are comparison sorts Any comparison

More information

A SIMPLE APPROXIMATION ALGORITHM FOR NONOVERLAPPING LOCAL ALIGNMENTS (WEIGHTED INDEPENDENT SETS OF AXIS PARALLEL RECTANGLES)

A SIMPLE APPROXIMATION ALGORITHM FOR NONOVERLAPPING LOCAL ALIGNMENTS (WEIGHTED INDEPENDENT SETS OF AXIS PARALLEL RECTANGLES) Chapter 1 A SIMPLE APPROXIMATION ALGORITHM FOR NONOVERLAPPING LOCAL ALIGNMENTS (WEIGHTED INDEPENDENT SETS OF AXIS PARALLEL RECTANGLES) Piotr Berman Department of Computer Science & Engineering Pennsylvania

More information

Fast and Simple Algorithms for Weighted Perfect Matching

Fast and Simple Algorithms for Weighted Perfect Matching Fast and Simple Algorithms for Weighted Perfect Matching Mirjam Wattenhofer, Roger Wattenhofer {mirjam.wattenhofer,wattenhofer}@inf.ethz.ch, Department of Computer Science, ETH Zurich, Switzerland Abstract

More information

Distributed minimum spanning tree problem

Distributed minimum spanning tree problem Distributed minimum spanning tree problem Juho-Kustaa Kangas 24th November 2012 Abstract Given a connected weighted undirected graph, the minimum spanning tree problem asks for a spanning subtree with

More information

A novel algorithm to determine the leaf (leaves) of a binary tree from its preorder and postorder traversals

A novel algorithm to determine the leaf (leaves) of a binary tree from its preorder and postorder traversals Journal of Algorithms and Computation journal homepage: http://jac.ut.ac.ir A novel algorithm to determine the leaf (leaves) of a binary tree from its preorder and postorder traversals N. Aghaieabiane

More information

Graph Algorithms Using Depth First Search

Graph Algorithms Using Depth First Search Graph Algorithms Using Depth First Search Analysis of Algorithms Week 8, Lecture 1 Prepared by John Reif, Ph.D. Distinguished Professor of Computer Science Duke University Graph Algorithms Using Depth

More information

Optimum Alphabetic Binary Trees T. C. Hu and J. D. Morgenthaler Department of Computer Science and Engineering, School of Engineering, University of C

Optimum Alphabetic Binary Trees T. C. Hu and J. D. Morgenthaler Department of Computer Science and Engineering, School of Engineering, University of C Optimum Alphabetic Binary Trees T. C. Hu and J. D. Morgenthaler Department of Computer Science and Engineering, School of Engineering, University of California, San Diego CA 92093{0114, USA Abstract. We

More information

Tilings of the Euclidean plane

Tilings of the Euclidean plane Tilings of the Euclidean plane Yan Der, Robin, Cécile January 9, 2017 Abstract This document gives a quick overview of a eld of mathematics which lies in the intersection of geometry and algebra : tilings.

More information

st-orientations September 29, 2005

st-orientations September 29, 2005 st-orientations September 29, 2005 Introduction Let G = (V, E) be an undirected biconnected graph of n nodes and m edges. The main problem this chapter deals with is different algorithms for orienting

More information

16 Greedy Algorithms

16 Greedy Algorithms 16 Greedy Algorithms Optimization algorithms typically go through a sequence of steps, with a set of choices at each For many optimization problems, using dynamic programming to determine the best choices

More information

A technique for adding range restrictions to. August 30, Abstract. In a generalized searching problem, a set S of n colored geometric objects

A technique for adding range restrictions to. August 30, Abstract. In a generalized searching problem, a set S of n colored geometric objects A technique for adding range restrictions to generalized searching problems Prosenjit Gupta Ravi Janardan y Michiel Smid z August 30, 1996 Abstract In a generalized searching problem, a set S of n colored

More information

Assignment 1. Stefano Guerra. October 11, The following observation follows directly from the definition of in order and pre order traversal:

Assignment 1. Stefano Guerra. October 11, The following observation follows directly from the definition of in order and pre order traversal: Assignment 1 Stefano Guerra October 11, 2016 1 Problem 1 Describe a recursive algorithm to reconstruct an arbitrary binary tree, given its preorder and inorder node sequences as input. First, recall that

More information

A New Graph Triconnectivity Algorithm and Its Parallelization*

A New Graph Triconnectivity Algorithm and Its Parallelization* In COMBINATORICA, vol. 12, 1992, pp. 53-76. (Figures not yet included in this file.) A New Graph Triconnectivity Algorithm and Its Parallelization* Gary L. Miller University of Southern California, Los

More information

Treaps. 1 Binary Search Trees (BSTs) CSE341T/CSE549T 11/05/2014. Lecture 19

Treaps. 1 Binary Search Trees (BSTs) CSE341T/CSE549T 11/05/2014. Lecture 19 CSE34T/CSE549T /05/04 Lecture 9 Treaps Binary Search Trees (BSTs) Search trees are tree-based data structures that can be used to store and search for items that satisfy a total order. There are many types

More information

FOUR EDGE-INDEPENDENT SPANNING TREES 1

FOUR EDGE-INDEPENDENT SPANNING TREES 1 FOUR EDGE-INDEPENDENT SPANNING TREES 1 Alexander Hoyer and Robin Thomas School of Mathematics Georgia Institute of Technology Atlanta, Georgia 30332-0160, USA ABSTRACT We prove an ear-decomposition theorem

More information

Lecture 2 - Graph Theory Fundamentals - Reachability and Exploration 1

Lecture 2 - Graph Theory Fundamentals - Reachability and Exploration 1 CME 305: Discrete Mathematics and Algorithms Instructor: Professor Aaron Sidford (sidford@stanford.edu) January 11, 2018 Lecture 2 - Graph Theory Fundamentals - Reachability and Exploration 1 In this lecture

More information

Efficient pebbling for list traversal synopses

Efficient pebbling for list traversal synopses Efficient pebbling for list traversal synopses Yossi Matias Ely Porat Tel Aviv University Bar-Ilan University & Tel Aviv University Abstract 1 Introduction 1.1 Applications Consider a program P running

More information

Binary search trees. Binary search trees are data structures based on binary trees that support operations on dynamic sets.

Binary search trees. Binary search trees are data structures based on binary trees that support operations on dynamic sets. COMP3600/6466 Algorithms 2018 Lecture 12 1 Binary search trees Reading: Cormen et al, Sections 12.1 to 12.3 Binary search trees are data structures based on binary trees that support operations on dynamic

More information

PAPER Constructing the Suffix Tree of a Tree with a Large Alphabet

PAPER Constructing the Suffix Tree of a Tree with a Large Alphabet IEICE TRANS. FUNDAMENTALS, VOL.E8??, NO. JANUARY 999 PAPER Constructing the Suffix Tree of a Tree with a Large Alphabet Tetsuo SHIBUYA, SUMMARY The problem of constructing the suffix tree of a tree is

More information

Binary search trees 3. Binary search trees. Binary search trees 2. Reading: Cormen et al, Sections 12.1 to 12.3

Binary search trees 3. Binary search trees. Binary search trees 2. Reading: Cormen et al, Sections 12.1 to 12.3 Binary search trees Reading: Cormen et al, Sections 12.1 to 12.3 Binary search trees 3 Binary search trees are data structures based on binary trees that support operations on dynamic sets. Each element

More information

Lowest Common Ancestor(LCA)

Lowest Common Ancestor(LCA) Lowest Common Ancestor(LCA) Fayssal El Moufatich Technische Universität München St. Petersburg JASS 2008 1 Introduction LCA problem is one of the most fundamental algorithmic problems on trees. It is concerned

More information

Localization in Graphs. Richardson, TX Azriel Rosenfeld. Center for Automation Research. College Park, MD

Localization in Graphs. Richardson, TX Azriel Rosenfeld. Center for Automation Research. College Park, MD CAR-TR-728 CS-TR-3326 UMIACS-TR-94-92 Samir Khuller Department of Computer Science Institute for Advanced Computer Studies University of Maryland College Park, MD 20742-3255 Localization in Graphs Azriel

More information

An Ecient Approximation Algorithm for the. File Redistribution Scheduling Problem in. Fully Connected Networks. Abstract

An Ecient Approximation Algorithm for the. File Redistribution Scheduling Problem in. Fully Connected Networks. Abstract An Ecient Approximation Algorithm for the File Redistribution Scheduling Problem in Fully Connected Networks Ravi Varadarajan Pedro I. Rivera-Vega y Abstract We consider the problem of transferring a set

More information

Computing intersections in a set of line segments: the Bentley-Ottmann algorithm

Computing intersections in a set of line segments: the Bentley-Ottmann algorithm Computing intersections in a set of line segments: the Bentley-Ottmann algorithm Michiel Smid October 14, 2003 1 Introduction In these notes, we introduce a powerful technique for solving geometric problems.

More information

A Linear-Processor Algorithm for Depth-First Search in Planar Graphs

A Linear-Processor Algorithm for Depth-First Search in Planar Graphs Purdue University Purdue e-pubs Department of Computer Science Technical Reports Department of Computer Science 1988 A Linear-Processor Algorithm for Depth-First Search in Planar Graphs Gregory E. Shannon

More information

Fast Parallel and Serial Approximate. Consider the string matching problem, where dierences between characters

Fast Parallel and Serial Approximate. Consider the string matching problem, where dierences between characters 7 Fast Parallel and Serial Approximate String Matching Consider the string matching problem, where dierences between characters of the pattern and characters of the text are allowed. Each dierence is due

More information

Multiway Blockwise In-place Merging

Multiway Blockwise In-place Merging Multiway Blockwise In-place Merging Viliam Geffert and Jozef Gajdoš Institute of Computer Science, P.J.Šafárik University, Faculty of Science Jesenná 5, 041 54 Košice, Slovak Republic viliam.geffert@upjs.sk,

More information

A General Class of Heuristics for Minimum Weight Perfect Matching and Fast Special Cases with Doubly and Triply Logarithmic Errors 1

A General Class of Heuristics for Minimum Weight Perfect Matching and Fast Special Cases with Doubly and Triply Logarithmic Errors 1 Algorithmica (1997) 18: 544 559 Algorithmica 1997 Springer-Verlag New York Inc. A General Class of Heuristics for Minimum Weight Perfect Matching and Fast Special Cases with Doubly and Triply Logarithmic

More information

On the Complexity of the Policy Improvement Algorithm. for Markov Decision Processes

On the Complexity of the Policy Improvement Algorithm. for Markov Decision Processes On the Complexity of the Policy Improvement Algorithm for Markov Decision Processes Mary Melekopoglou Anne Condon Computer Sciences Department University of Wisconsin - Madison 0 West Dayton Street Madison,

More information

On the other hand, the main disadvantage of the amortized approach is that it cannot be applied in real-time programs, where the worst-case bound on t

On the other hand, the main disadvantage of the amortized approach is that it cannot be applied in real-time programs, where the worst-case bound on t Randomized Meldable Priority Queues Anna Gambin and Adam Malinowski Instytut Informatyki, Uniwersytet Warszawski, Banacha 2, Warszawa 02-097, Poland, faniag,amalg@mimuw.edu.pl Abstract. We present a practical

More information

An Optimal Parallel Algorithm for Merging using Multiselection y

An Optimal Parallel Algorithm for Merging using Multiselection y An Optimal Parallel Algorithm for Merging using Multiselection y Narsingh Deo Amit Jain Muralidhar Medidi Department of Computer Science, University of Central Florida, Orlando, FL 32816 Keywords: selection,

More information

Courant Institute. This research was supported in part by NSF grant DCR and by an IBM faculty development award.

Courant Institute. This research was supported in part by NSF grant DCR and by an IBM faculty development award. The Accelerated Centroid Decomposition Technique For Optimal Parallel Tree Evaluation In Logarithmic Time by Richard Cole Uzi Vishkin Ultracomputer Note #108 Computer Science Department Technical Report

More information

would be included in is small: to be exact. Thus with probability1, the same partition n+1 n+1 would be produced regardless of whether p is in the inp

would be included in is small: to be exact. Thus with probability1, the same partition n+1 n+1 would be produced regardless of whether p is in the inp 1 Introduction 1.1 Parallel Randomized Algorihtms Using Sampling A fundamental strategy used in designing ecient algorithms is divide-and-conquer, where that input data is partitioned into several subproblems

More information

Parallel Algorithms for (PRAM) Computers & Some Parallel Algorithms. Reference : Horowitz, Sahni and Rajasekaran, Computer Algorithms

Parallel Algorithms for (PRAM) Computers & Some Parallel Algorithms. Reference : Horowitz, Sahni and Rajasekaran, Computer Algorithms Parallel Algorithms for (PRAM) Computers & Some Parallel Algorithms Reference : Horowitz, Sahni and Rajasekaran, Computer Algorithms Part 2 1 3 Maximum Selection Problem : Given n numbers, x 1, x 2,, x

More information

4 Basics of Trees. Petr Hliněný, FI MU Brno 1 FI: MA010: Trees and Forests

4 Basics of Trees. Petr Hliněný, FI MU Brno 1 FI: MA010: Trees and Forests 4 Basics of Trees Trees, actually acyclic connected simple graphs, are among the simplest graph classes. Despite their simplicity, they still have rich structure and many useful application, such as in

More information

on Mesh Connected Computers and Meshes with Multiple Broadcasting Ion Stoica Abstract

on Mesh Connected Computers and Meshes with Multiple Broadcasting Ion Stoica Abstract Time-Optimal Algorithms for Generalized Dominance Computation and Related Problems on Mesh Connected Computers and Meshes with Multiple Broadcasting Ion Stoica Abstract The generalized dominance computation

More information

where is a constant, 0 < <. In other words, the ratio between the shortest and longest paths from a node to a leaf is at least. An BB-tree allows ecie

where is a constant, 0 < <. In other words, the ratio between the shortest and longest paths from a node to a leaf is at least. An BB-tree allows ecie Maintaining -balanced Trees by Partial Rebuilding Arne Andersson Department of Computer Science Lund University Box 8 S-22 00 Lund Sweden Abstract The balance criterion dening the class of -balanced trees

More information

Notes on Binary Dumbbell Trees

Notes on Binary Dumbbell Trees Notes on Binary Dumbbell Trees Michiel Smid March 23, 2012 Abstract Dumbbell trees were introduced in [1]. A detailed description of non-binary dumbbell trees appears in Chapter 11 of [3]. These notes

More information

Lecture 15. Error-free variable length schemes: Shannon-Fano code

Lecture 15. Error-free variable length schemes: Shannon-Fano code Lecture 15 Agenda for the lecture Bounds for L(X) Error-free variable length schemes: Shannon-Fano code 15.1 Optimal length nonsingular code While we do not know L(X), it is easy to specify a nonsingular

More information

arxiv: v3 [cs.ds] 18 Apr 2011

arxiv: v3 [cs.ds] 18 Apr 2011 A tight bound on the worst-case number of comparisons for Floyd s heap construction algorithm Ioannis K. Paparrizos School of Computer and Communication Sciences Ècole Polytechnique Fèdèrale de Lausanne

More information

Finger Search Trees with Constant. Insertion Time. Gerth Stlting Brodal. Max-Planck-Institut fur Informatik. Im Stadtwald. D Saarbrucken

Finger Search Trees with Constant. Insertion Time. Gerth Stlting Brodal. Max-Planck-Institut fur Informatik. Im Stadtwald. D Saarbrucken Finger Search Trees with Constant Insertion Time Gerth Stlting Brodal Max-Planck-Institut fur Informatik Im Stadtwald D-66123 Saarbrucken Germany Email: brodal@mpi-sb.mpg.de September 26, 1997 Abstract

More information

An improved algorithm to reconstruct a binary tree from its inorder and postorder traversals

An improved algorithm to reconstruct a binary tree from its inorder and postorder traversals Journal of Algorithms and Computation journal homepage: http://jac.ut.ac.ir An improved algorithm to reconstruct a binary tree from its inorder and postorder traversals Niloofar Aghaieabiane 1, Henk Koppelaar

More information

r (1,1) r (2,4) r (2,5) r(2,6) r (1,3) r (1,2)

r (1,1) r (2,4) r (2,5) r(2,6) r (1,3) r (1,2) Routing on Trees via Matchings? Alan Roberts 1, Antonis Symvonis 1 and Louxin Zhang 2 1 Department of Computer Science, University of Sydney, N.S.W. 2006, Australia 2 Department of Computer Science, University

More information

Algorithms. Lecture Notes 5

Algorithms. Lecture Notes 5 Algorithms. Lecture Notes 5 Dynamic Programming for Sequence Comparison The linear structure of the Sequence Comparison problem immediately suggests a dynamic programming approach. Naturally, our sub-instances

More information

15 212: Principles of Programming. Some Notes on Induction

15 212: Principles of Programming. Some Notes on Induction 5 22: Principles of Programming Some Notes on Induction Michael Erdmann Spring 20 These notes provide a brief introduction to induction for proving properties of ML programs. We assume that the reader

More information

Implementation of Hopcroft's Algorithm

Implementation of Hopcroft's Algorithm Implementation of Hopcroft's Algorithm Hang Zhou 19 December 2009 Abstract Minimization of a deterministic nite automaton(dfa) is a well-studied problem of formal language. An ecient algorithm for this

More information

A Simplified Correctness Proof for a Well-Known Algorithm Computing Strongly Connected Components

A Simplified Correctness Proof for a Well-Known Algorithm Computing Strongly Connected Components A Simplified Correctness Proof for a Well-Known Algorithm Computing Strongly Connected Components Ingo Wegener FB Informatik, LS2, Univ. Dortmund, 44221 Dortmund, Germany wegener@ls2.cs.uni-dortmund.de

More information

Section 5.5. Left subtree The left subtree of a vertex V on a binary tree is the graph formed by the left child L of V, the descendents

Section 5.5. Left subtree The left subtree of a vertex V on a binary tree is the graph formed by the left child L of V, the descendents Section 5.5 Binary Tree A binary tree is a rooted tree in which each vertex has at most two children and each child is designated as being a left child or a right child. Thus, in a binary tree, each vertex

More information

Lecture 8: The Traveling Salesman Problem

Lecture 8: The Traveling Salesman Problem Lecture 8: The Traveling Salesman Problem Let G = (V, E) be an undirected graph. A Hamiltonian cycle of G is a cycle that visits every vertex v V exactly once. Instead of Hamiltonian cycle, we sometimes

More information

There are many other applications like constructing the expression tree from the postorder expression. I leave you with an idea as how to do it.

There are many other applications like constructing the expression tree from the postorder expression. I leave you with an idea as how to do it. Programming, Data Structures and Algorithms Prof. Hema Murthy Department of Computer Science and Engineering Indian Institute of Technology, Madras Lecture 49 Module 09 Other applications: expression tree

More information

A Simplied NP-complete MAXSAT Problem. Abstract. It is shown that the MAX2SAT problem is NP-complete even if every variable

A Simplied NP-complete MAXSAT Problem. Abstract. It is shown that the MAX2SAT problem is NP-complete even if every variable A Simplied NP-complete MAXSAT Problem Venkatesh Raman 1, B. Ravikumar 2 and S. Srinivasa Rao 1 1 The Institute of Mathematical Sciences, C. I. T. Campus, Chennai 600 113. India 2 Department of Computer

More information

ADAPTIVE SORTING WITH AVL TREES

ADAPTIVE SORTING WITH AVL TREES ADAPTIVE SORTING WITH AVL TREES Amr Elmasry Computer Science Department Alexandria University Alexandria, Egypt elmasry@alexeng.edu.eg Abstract A new adaptive sorting algorithm is introduced. The new implementation

More information

A Note on Scheduling Parallel Unit Jobs on Hypercubes

A Note on Scheduling Parallel Unit Jobs on Hypercubes A Note on Scheduling Parallel Unit Jobs on Hypercubes Ondřej Zajíček Abstract We study the problem of scheduling independent unit-time parallel jobs on hypercubes. A parallel job has to be scheduled between

More information

FUTURE communication networks are expected to support

FUTURE communication networks are expected to support 1146 IEEE/ACM TRANSACTIONS ON NETWORKING, VOL 13, NO 5, OCTOBER 2005 A Scalable Approach to the Partition of QoS Requirements in Unicast and Multicast Ariel Orda, Senior Member, IEEE, and Alexander Sprintson,

More information

Interval Stabbing Problems in Small Integer Ranges

Interval Stabbing Problems in Small Integer Ranges Interval Stabbing Problems in Small Integer Ranges Jens M. Schmidt Freie Universität Berlin, Germany Enhanced version of August 2, 2010 Abstract Given a set I of n intervals, a stabbing query consists

More information

Efficient Parallel Binary Search on Sorted Arrays

Efficient Parallel Binary Search on Sorted Arrays Purdue University Purdue e-pubs Computer Science Technical Reports Department of Computer Science 1990 Efficient Parallel Binary Search on Sorted Arrays Danny Z. Chen Report Number: 90-1009 Chen, Danny

More information

Module 7. Independent sets, coverings. and matchings. Contents

Module 7. Independent sets, coverings. and matchings. Contents Module 7 Independent sets, coverings Contents and matchings 7.1 Introduction.......................... 152 7.2 Independent sets and coverings: basic equations..... 152 7.3 Matchings in bipartite graphs................

More information

A Linear Time Algorithm for the Minimum Spanning Tree Problem. on a Planar Graph. Tomomi MATSUI. (January 1994 )

A Linear Time Algorithm for the Minimum Spanning Tree Problem. on a Planar Graph. Tomomi MATSUI. (January 1994 ) A Linear Time Algorithm for the Minimum Spanning Tree Problem on a Planar Graph Tomomi MATSUI (January 994 ) Department of Mathematical Engineering and Information Physics Faculty of Engineering, University

More information

Verifying a Border Array in Linear Time

Verifying a Border Array in Linear Time Verifying a Border Array in Linear Time František Franěk Weilin Lu P. J. Ryan W. F. Smyth Yu Sun Lu Yang Algorithms Research Group Department of Computing & Software McMaster University Hamilton, Ontario

More information

Binary Search Trees Treesort

Binary Search Trees Treesort Treesort CS 311 Data Structures and Algorithms Lecture Slides Friday, November 13, 2009 Glenn G. Chappell Department of Computer Science University of Alaska Fairbanks CHAPPELLG@member.ams.org 2005 2009

More information

Lecture 3 February 20, 2007

Lecture 3 February 20, 2007 6.897: Advanced Data Structures Spring 2007 Prof. Erik Demaine Lecture 3 February 20, 2007 Scribe: Hui Tang 1 Overview In the last lecture we discussed Binary Search Trees and the many bounds which achieve

More information

Lecture 2 February 4, 2010

Lecture 2 February 4, 2010 6.897: Advanced Data Structures Spring 010 Prof. Erik Demaine Lecture February 4, 010 1 Overview In the last lecture we discussed Binary Search Trees(BST) and introduced them as a model of computation.

More information

How many leaves on the decision tree? There are n! leaves, because every permutation appears at least once.

How many leaves on the decision tree? There are n! leaves, because every permutation appears at least once. Chapter 8. Sorting in Linear Time Types of Sort Algorithms The only operation that may be used to gain order information about a sequence is comparison of pairs of elements. Quick Sort -- comparison-based

More information

Topics. Trees Vojislav Kecman. Which graphs are trees? Terminology. Terminology Trees as Models Some Tree Theorems Applications of Trees CMSC 302

Topics. Trees Vojislav Kecman. Which graphs are trees? Terminology. Terminology Trees as Models Some Tree Theorems Applications of Trees CMSC 302 Topics VCU, Department of Computer Science CMSC 302 Trees Vojislav Kecman Terminology Trees as Models Some Tree Theorems Applications of Trees Binary Search Tree Decision Tree Tree Traversal Spanning Trees

More information

Fundamental Properties of Graphs

Fundamental Properties of Graphs Chapter three In many real-life situations we need to know how robust a graph that represents a certain network is, how edges or vertices can be removed without completely destroying the overall connectivity,

More information

On k-dimensional Balanced Binary Trees*

On k-dimensional Balanced Binary Trees* journal of computer and system sciences 52, 328348 (1996) article no. 0025 On k-dimensional Balanced Binary Trees* Vijay K. Vaishnavi Department of Computer Information Systems, Georgia State University,

More information

A more efficient algorithm for perfect sorting by reversals

A more efficient algorithm for perfect sorting by reversals A more efficient algorithm for perfect sorting by reversals Sèverine Bérard 1,2, Cedric Chauve 3,4, and Christophe Paul 5 1 Département de Mathématiques et d Informatique Appliquée, INRA, Toulouse, France.

More information

Stores a collection of elements each with an associated key value

Stores a collection of elements each with an associated key value CH9. PRIORITY QUEUES ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN JAVA, GOODRICH, TAMASSIA AND GOLDWASSER (WILEY 201) PRIORITY QUEUES Stores a collection

More information

Ma/CS 6b Class 26: Art Galleries and Politicians

Ma/CS 6b Class 26: Art Galleries and Politicians Ma/CS 6b Class 26: Art Galleries and Politicians By Adam Sheffer The Art Gallery Problem Problem. We wish to place security cameras at a gallery, such that they cover it completely. Every camera can cover

More information

Programming II (CS300)

Programming II (CS300) 1 Programming II (CS300) Chapter 11: Binary Search Trees MOUNA KACEM mouna@cs.wisc.edu Fall 2018 General Overview of Data Structures 2 Introduction to trees 3 Tree: Important non-linear data structure

More information

The Encoding Complexity of Network Coding

The Encoding Complexity of Network Coding The Encoding Complexity of Network Coding Michael Langberg Alexander Sprintson Jehoshua Bruck California Institute of Technology Email: mikel,spalex,bruck @caltech.edu Abstract In the multicast network

More information

Bipartite Roots of Graphs

Bipartite Roots of Graphs Bipartite Roots of Graphs Lap Chi Lau Department of Computer Science University of Toronto Graph H is a root of graph G if there exists a positive integer k such that x and y are adjacent in G if and only

More information

Binary Heaps in Dynamic Arrays

Binary Heaps in Dynamic Arrays Yufei Tao ITEE University of Queensland We have already learned that the binary heap serves as an efficient implementation of a priority queue. Our previous discussion was based on pointers (for getting

More information

Trees. 3. (Minimally Connected) G is connected and deleting any of its edges gives rise to a disconnected graph.

Trees. 3. (Minimally Connected) G is connected and deleting any of its edges gives rise to a disconnected graph. Trees 1 Introduction Trees are very special kind of (undirected) graphs. Formally speaking, a tree is a connected graph that is acyclic. 1 This definition has some drawbacks: given a graph it is not trivial

More information

2 Eulerian digraphs and oriented trees.

2 Eulerian digraphs and oriented trees. 2 Eulerian digraphs and oriented trees. A famous problem which goes back to Euler asks for what graphs G is there a closed walk which uses every edge exactly once. (There is also a version for non-closed

More information

Search Trees. Undirected graph Directed graph Tree Binary search tree

Search Trees. Undirected graph Directed graph Tree Binary search tree Search Trees Undirected graph Directed graph Tree Binary search tree 1 Binary Search Tree Binary search key property: Let x be a node in a binary search tree. If y is a node in the left subtree of x, then

More information

Decreasing the Diameter of Bounded Degree Graphs

Decreasing the Diameter of Bounded Degree Graphs Decreasing the Diameter of Bounded Degree Graphs Noga Alon András Gyárfás Miklós Ruszinkó February, 00 To the memory of Paul Erdős Abstract Let f d (G) denote the minimum number of edges that have to be

More information

Ecient Implementation of Sorting Algorithms on Asynchronous Distributed-Memory Machines

Ecient Implementation of Sorting Algorithms on Asynchronous Distributed-Memory Machines Ecient Implementation of Sorting Algorithms on Asynchronous Distributed-Memory Machines Zhou B. B., Brent R. P. and Tridgell A. y Computer Sciences Laboratory The Australian National University Canberra,

More information

CH 8. HEAPS AND PRIORITY QUEUES

CH 8. HEAPS AND PRIORITY QUEUES CH 8. HEAPS AND PRIORITY QUEUES ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN C++, GOODRICH, TAMASSIA AND MOUNT (WILEY 2004) AND SLIDES FROM NANCY

More information

Chapter 3 Trees. Theorem A graph T is a tree if, and only if, every two distinct vertices of T are joined by a unique path.

Chapter 3 Trees. Theorem A graph T is a tree if, and only if, every two distinct vertices of T are joined by a unique path. Chapter 3 Trees Section 3. Fundamental Properties of Trees Suppose your city is planning to construct a rapid rail system. They want to construct the most economical system possible that will meet the

More information

Graph Theory Questions from Past Papers

Graph Theory Questions from Past Papers Graph Theory Questions from Past Papers Bilkent University, Laurence Barker, 19 October 2017 Do not forget to justify your answers in terms which could be understood by people who know the background theory

More information

EE 368. Week 6 (Notes)

EE 368. Week 6 (Notes) EE 368 Week 6 (Notes) 1 Expression Trees Binary trees provide an efficient data structure for representing expressions with binary operators. Root contains the operator Left and right children contain

More information

Finger Search Trees with Constant Insertion Time. Gerth Stlting Brodal. Max-Planck-Institut fur Informatik. Im Stadtwald, D Saarbrucken, Germany

Finger Search Trees with Constant Insertion Time. Gerth Stlting Brodal. Max-Planck-Institut fur Informatik. Im Stadtwald, D Saarbrucken, Germany Finger Search Trees with Constant Insertion Time Gerth Stlting Brodal Max-Planck-Institut fur Informatik Im Stadtwald, D-66123 Saarbrucken, Germany Abstract We consider the problem of implementing nger

More information

Lecture 3: Art Gallery Problems and Polygon Triangulation

Lecture 3: Art Gallery Problems and Polygon Triangulation EECS 396/496: Computational Geometry Fall 2017 Lecture 3: Art Gallery Problems and Polygon Triangulation Lecturer: Huck Bennett In this lecture, we study the problem of guarding an art gallery (specified

More information

Pebble Sets in Convex Polygons

Pebble Sets in Convex Polygons 2 1 Pebble Sets in Convex Polygons Kevin Iga, Randall Maddox June 15, 2005 Abstract Lukács and András posed the problem of showing the existence of a set of n 2 points in the interior of a convex n-gon

More information

Graph Algorithms. Tours in Graphs. Graph Algorithms

Graph Algorithms. Tours in Graphs. Graph Algorithms Graph Algorithms Tours in Graphs Graph Algorithms Special Paths and Cycles in Graphs Euler Path: A path that traverses all the edges of the graph exactly once. Euler Cycle: A cycle that traverses all the

More information

CS2 Algorithms and Data Structures Note 6

CS2 Algorithms and Data Structures Note 6 CS Algorithms and Data Structures Note 6 Priority Queues and Heaps In this lecture, we will discuss priority queues, another important ADT. As stacks and queues, priority queues store arbitrary collections

More information

Applied Mathematics Letters. Graph triangulations and the compatibility of unrooted phylogenetic trees

Applied Mathematics Letters. Graph triangulations and the compatibility of unrooted phylogenetic trees Applied Mathematics Letters 24 (2011) 719 723 Contents lists available at ScienceDirect Applied Mathematics Letters journal homepage: www.elsevier.com/locate/aml Graph triangulations and the compatibility

More information