arxiv:cs/ v2 [cs.ds] 14 Nov 2006

Size: px
Start display at page:

Download "arxiv:cs/ v2 [cs.ds] 14 Nov 2006"

Transcription

1 Linear-Time Pointer-Machine Algorithms for Path-Evaluation Problems on Trees and Graphs arxiv:cs/ v2 [cs.ds] 14 Nov 2006 Adam L. Buchsbaum Loukas Georgiadis Haim Kaplan Anne Rogers Robert E. Tarjan October 31, 2006 Abstract Jeffery R. Westbrook We present algorithms that run in linear time on pointer machines for a collection of problems, each of which either directly or indirectly requires the evaluation of a function defined on paths in a tree. These problems previously had linear-time algorithms but only for random-access machines (RAMs); the best pointer-machine algorithms were super-linear by an inverse-ackermann-function factor. Our algorithms are also simpler, in some cases substantially, than the previous linear-time RAM algorithms. Our improvements come primarily from three new ideas: a refined analysis of path compression that gives a linear bound if the compressions favor certain nodes, a pointer-based radix sort as a replacement for table-based methods, and a more careful partitioning of a tree into easily managed parts. Our algorithms compute nearest common ancestors off-line, verify and construct minimum spanning trees, do interval analysis on a flowgraph, find the dominators of a flowgraph, and build the component tree of a weighted tree. 1 Introduction We study six problems off-line computation of nearest common ancestors (NCAs), verification and construction of minimum spanning trees (MSTs), interval analysis of flowgraphs, finding dominators in flowgraphs, and building the component tree of a weighted tree that directly or indirectly require the evaluation of a function defined on paths in a tree. Each of these problems has a linear-time algorithm on a RAM, but This work is partially covered by the extended abstracts, Linear-Time Pointer-Machine Algorithms for Least Common Ancestors, MST Verification, and Dominators, Proc. 30th ACM Symp. on Theory of Computing, pp , 1998, and Finding Dominators Revisited, Proc. 15th ACM-SIAM Symp. on Discrete Algorithms, pp , AT&T Labs Research, Shannon Laboratory, 180 Park Ave., Florham Park, NJ 07932, USA; alb@research.att.com. Dept. of Computer Science, University of Aarhus, IT-parken, Aabogade 34, DK-8200 Aarhus N, Denmark; loukas@daimi.au.dk. Work partially done at Princeton University and partially supported by the National Science Foundation under the Aladdin Project, Grant No. CCR School of Mathematical Sciences, Tel Aviv University, Tel Aviv, Israel; haimk@math.tau.ac.il. Work partially done while a member of AT&T Labs. Dept. of Computer Science, University of Chicago, 1100 E 58th Street, Chicago, IL 60637, USA; amr@cs.uchicago.edu. Work partially done while a member of AT&T Labs. Dept. of Computer Science, Princeton University, Princeton NJ, 08544, USA; and Hewlett-Packard, Palo Alto, CA; ret@cs.princeton.edu. Work at Princeton University partially supported by the National Science Foundation under the Aladdin Project, Grant No. CCR Los Angeles, CA, USA; jwestbrook@acm.org. Work partially done while a member of AT&T Labs. 1

2 Table 1: Time bounds. n is the number of vertices, and m is either the number of edges/arcs for graph problems or the number of NCA queries for the NCA problem. α(m,n) is the standard functional inverse of the Ackermann function. Problem Previous Pointer-Machine Bound Previous RAM Bound Off-line NCAs O(mα(m, n) + n) [2] O(n + m) [38, 52] MST Verification O(mα(m, n) + n) [58] O(n + m) [22, 40] MST Construction O(mα(m, n) + n) [18] O(n + m) [26, 39] Interval Analysis O(mα(m, n) + n) [57] O(n + m) [30, 57] Dominators O(mα(m, n) + n) [43] O(n + m) [8, 15] Component Trees O(mα(m, n) + n) O(n + m) [62] the fastest pointer-machine algorithm is slower by an inverse-ackermann-function factor. 1 (See Table 1.) A pointer machine [59] allows binary comparisons and arithmetic operations on data, dereferencing of pointers, and equality tests on pointers. It does not permit pointer arithmetic or tests on pointers other than testing for equality and is thus less powerful than the RAM model [1]. Pointer machines are powerful enough to simulate functional programming languages like LISP and ML. Often, though, the lack of random access complicates the design of efficient pointer machine algorithms; the RAM algorithms for the problems we consider rely on O(1)-time table lookup methods that are not implementable on a pointer machine. Nevertheless, we are able to overcome the weaknesses of the pointer machine model and develop linear-time algorithms for all six problems. Not only are our algorithms asymptotically as fast as the fastest RAM algorithms, they are simpler too, in some cases substantially. Our improvements come mainly from three new ideas. The first is a refined analysis of path compression. Path compression is a well-known technique first used to speed up the standard disjoint-set-union (DSU) data structure [56] and later extended to speed up the evaluation of functions defined on paths in trees [58]. Our applications use either the DSU structure or path evaluation for the function minimum or maximum, or both. We show that, under a certain restriction on the compressions satisfied by our applications, compression takes constant rather than inverse-ackermann amortized time. The second new idea is to replace the table-based methods of the RAM algorithms with a pointer-based radix sort. Each of the RAM algorithms precomputes answers to small subproblems, stores the answers in a table, and looks up the answers by random access. If the size of the subproblems is small enough, the total size of all distinct subproblems and the total time to solve them are linear (or even sublinear) in the size of the original problem. Our alternative approach is to construct a pointer-based encoding of each subproblem, group isomorphic subproblems together using a pointer-based radix sort, solve one instance of each group of isomorphic subproblems, and transfer its solution to the isomorphic subproblems, all of which can be done on a pointer machine. The third new idea is to change the partitioning strategy. In order to reduce the original problem to a collection of small subproblems, the RAM algorithms partition a tree corresponding to the original problem into small subtrees. For some of the problems, partitioning the entire tree into subtrees produces serious technical complications; this is especially true of the dominators problem. Instead, for all but one of the problems we partition only the bottom part of the tree into small subtrees. For NCAs and MSTs, this 1 We use Tarjan s definition [56]. Let A(i,j) for i,j 1 be defined by A(1,j) = 2 j for j 1; A(i,1) = A(i 1,2) for i 2; anda(i,j) = A(i 1,A(i,j 1)) for i,j 2. Thenα(m,n) = min{i 1 : A(i, m/n ) > logn}. 2

3 together with our refined analysis of path compression suffices to yield a linear-time algorithm. For interval analysis and finding dominators, we also partition the remainder of the tree into a set of maximal disjoint paths. Only one of our applications, building a component tree, relies on the original idea of partitioning the entire tree into small subtrees. The remainder of our paper proceeds as follows. Section 2 formally defines the problems we consider and reviews previous work. Section 3 discusses disjoint set union, computing path minima on trees, and a refined analysis of path compression. Section 4 discusses the use of pointer-based radix sorting to solve a graph problem for a collection of many small instances. Sections 5 through 9 discuss our applications: NCAs, MSTs, flowgraph interval analysis, finding dominators, and building a component tree, respectively. Section 10 contains concluding remarks. Our paper is a significantly revised and improved combination of two conference papers [14, 32], including new results in Sections 7 and 9. 2 Problem Definitions and Previous Work Throughout this paper we denote the base-two logarithm by log. We assume n 2 throughout. 2.1 Nearest Common Ancestors Off-Line Nearest Common Ancestors: Given an n-node tree T rooted at node r and a set P of m node pairs, find, for each pair {v,w} in P, the nearest common ancestor of v and w in T, denoted by nca(v,w). The fastest previous pointer-machine algorithm is that of Aho, Hopcroft, and Ullman (AHU) [2], which runs in O(n+mα(m +n,n)) time. The AHU algorithm uses a DSU data structure; it runs in O(n+m) time on a RAM if this structure is implemented using the DSU algorithm of Gabow and Tarjan [30] for the special case in which the set of unions is known in advance. The first linear-time RAM algorithm was actually given by Harel and Tarjan [38]. Other linear-time RAM algorithms were given by Schieber and Vishkin [52], Bender and Farach-Colton [12], and Alstrup et al. [7]. There are several variants of the NCAs problem of increasing difficulty. For each but the last, there is a non-constant-factor gap between the running time of the fastest RAM and pointer-machine algorithms. Static On-Line: T is given a priori but P is given on-line: each NCA query must be answered before the next one is known. Linking Roots: T is given dynamically. Specifically, T is initially a forest of singleton nodes. Interspersed with the on-line NCA queries are on-line link(v, w) operations, each of which is given a pair of distinct roots v and w in the current forest and connects them by making v the parent of w. Adding Leaves: Like linking roots, only v is any node other than w and w is a singleton. General Linking: Like linking roots, only v can be any node that is not a descendant of w. Linking and Cutting: Like general linking, but with additional interspersed cut(v) operations, each of which is given a non-root node and makes it a root by disconnecting it from its parent. Harel and Tarjan [38] showed that the static on-line problem (and thus the more general variants) takes Ω(loglogn) time on a pointer machine for each query in the worst case. Alstrup and Thorup [10] gave 3

4 a matching O(n + m log log n)-time pointer-machine algorithm for general linking, which is also optimal for the static on-line, linking roots, and adding leaves variants. Earlier, Tsakalidis and van Leeuwen [63] gave such an algorithm for the static on-line variant, and a modified version of van Leeuwen s even-earlier algorithm [64] has the same bound for linking roots. The fastest known pointer-machine algorithm for linking and cutting is the O(n+mlogn)-time algorithm of Sleator and Tarjan [53]; Harel and Tarjan [38] conjectured that this is asymptotically optimal, and the results of Pǎtraşcu and Demaine [47] actually imply that lower bound in the cell-probe model. On a RAM, the fastest known algorithms takeθ(n+m) time for the static on-line [38,52] and adding leaves [27] variants, O(n+mα(m+n,n)) time for linking roots [38] and general linking [27], and O(n + mlogn) time for linking and cutting [53]. All these algorithms use O(n+m) space. For a more thorough survey of previous work see Alstrup et al. [7]. 2.2 Verification and Construction of Minimum Spanning Trees MST Construction: Given an undirected, connected graph G = (V, E) whose edges have real-valued weights, find a spanning tree of minimum total edge weight (an MST) of G. MST Verification: Given an undirected, connected graph G = (V, E) whose edges have real-valued weights and a spanning tree T of G, determine whether T is an MST ofg. In both problems, we denote by n and m the numbers of vertices and edges, respectively. Since G is connected and n 2, m n 1 implies n = O(m). MST construction has perhaps the longest and richest history of any network optimization problem; Graham and Hell [35] and Chazelle [18] provide excellent surveys. A sequence of faster-and-faster algorithms culminated in the randomized linear-time algorithm of Karger, Klein, and Tarjan [39]. This algorithm requires a RAM, but only for a computation equivalent to MST verification. It is also comparison-based: the only operations it does on edge weights are binary comparisons. Previously, Fredman and Willard [26] developed a linear-time RAM algorithm that is not comparison-based. Subsequently, Chazelle [18] developed a deterministic, comparison-based O(mα(m, n))-time pointer-machine algorithm, and Pettie and Ramachandran [49] developed a deterministic, comparison-based pointer-machine algorithm that runs in minimum time to within a constant factor. Getting an asymptotically tight bound on the running time of this algorithm remains an open problem. Although it remains open whether there is a comparison-based, deterministic linear-time MST construction algorithm, even for a RAM, such algorithms do exist for MST verification. Tarjan [58] gave a comparison-based, deterministic O(mα(m, n))-time pointer machine algorithm for verification. Komlós [41] showed how to do MST verification in O(m) comparisons, without providing an efficient way to determine which comparisons to do. Dixon, Rauch, and Tarjan [22] combined Tarjan s algorithm, Komlós s bound, and the tree partitioning technique of Gabow and Tarjan [30] to produce a comparison-based, deterministic linear-time RAM algorithm. King later gave a simplified algorithm [40]. 2.3 Interval Analysis of Flowgraphs A flowgraph G = (V,E,r) is a directed graph with a distinguished root vertex r such that every vertex is reachable from r. A depth-first spanning tree D of G is a spanning tree rooted at r defined by some depth-first search (DFS) of G, with the vertices numbered from 1 to n in preorder with respect to the DFS (the order in which the search first visits them). We identify vertices by their preorder number. We denote by n and m the number of vertices and edges ofg, respectively. 4

5 Interval Analysis: Given a flowgraph G and a depth-first spanning tree D of G, compute, for each vertex v, its head h(v), defined by h(v) = max{u : u is a proper ancestor of v ind and there is a path from v to u ing containing only descendants of u}, or null if this set is empty. The heads define a forest called the interval forest H, in which the parent of a vertex is its head. If v is any vertex, the descendants of v in H induce a strongly connected subgraph of G, which is called an interval; these intervals impose a hierarchy on the loop structure of G. Interval analysis has been used in global flow analysis of computer programs [3], in testing flowgraph reducibility [60], and in the construction of two maximally edge-disjoint spanning trees of a flowgraph [57]. Tarjan [57] gave ano(mα(m,n))-time pointer-machine algorithm for interval analysis using DSU. The Gabow-Tarjan DSU algorithm [30] reduces the running time of this algorithm too(m) on a RAM. 2.4 Finding Dominators Let G = (V,E,r) be a flowgraph. We denote by n and m the number of vertices and edges of G, respectively. Vertex v dominates vertex w if every path from r to w contains v, and v is the immediate dominator of w if every vertex that dominates w also dominates v. The dominators define a tree rooted at r, the dominator tree T, such that v dominates w if and only if v is an ancestor of w in T : for any vertex v r, the immediate dominator of v is its parent in T. Finding Dominators: Given a flowgraph G = (V, E, r), compute the immediate dominator of every vertex other than r. Finding dominators in flowgraphs is an elegant problem in graph theory with fundamental applications in global flow analysis and program optimization [4, 19, 24, 45] and additional applications in VLSI design [11], theoretical biology [5, 6] and constraint programming [51]. Lengauer and Tarjan [43] gave a practical O(mα(m, n))-time pointer-machine algorithm, capping a sequence of previous improvements [4,45,50,55]. Harel [37] claimed a linear-time RAM algorithm, but Alstrup et al. [8] found problems with some of his arguments and developed a corrected algorithm, which uses powerful bit-manipulation-based data structures. Buchsbaum et al. [15] proposed a simpler algorithm, but Georgiadis and Tarjan [32] gave a counterexample to their linear-time analysis and presented a way to repair and modify the algorithm so that it runs in linear time on a pointer machine; Buchsbaum et al. [15, Corrig.] gave a different resolution that results in a lineartime algorithm for a RAM. 2.5 Building a Component Tree Let T be a tree and let L be a list of the edges of T. The Kruskal tree of T with respect to L is a tree representing the connected components formed by deleting the edges of T and adding them back one-at-atime in the order of their occurrence inl. Specifically, K contains 2n 1 nodes. Its leaves are the nodes of T. Each internal node is a component formed by adding an edge (v,w) back to T ; its children are the two components that combine to form it. Component-Tree Construction: Given ann-node treet and a listlof its edges, build the corresponding Kruskal tree. 5

6 Compressed component trees (formed by adding edges a-group-at-a-time rather than one-at-a-time) have been used in shortest-path algorithms [48, 62]. It is straightforward to build a component tree or a compressed component tree in O(nα(n, n)) time on a pointer machine using DSU. The Gabow-Tarjan DSU algorithm [30] improves this algorithm to O(n) time on a RAM, as described by Thorup [62]. 3 Path Compression on Balanced Trees 3.1 Disjoint Set Union Via Path Compression and Balanced Unions The disjoint set union (DSU) problem calls for the maintenance of a dynamic partition of a universe U, initially consisting of singleton sets. Each set has a unique designated element; the designated element of a singleton set is its only element. Two operations are allowed: unite(v,w) Form the union of the sets whose designated elements arev and w, withv being the designated element of the new set. find(v) Return the designated element of the set containing element v. There are alternative, equivalent formulations of the DSU problem. In one [56, 59], each set is accessed by a label, rather than by a designated element. In another [61], sets have labels but can be accessed by any element. In yet another [61], each set is accessed by a canonical element, which in the case of a unite(v,w) operation can be freely chosen by the implementation to be either v or w. Our formulation more closely matches our uses. We denote bynthe total number of elements and bymthe total number of finds. The standard solution to the DSU problem [56, 61] represents the sets by rooted trees in a forest. Each tree represents a set, whose elements are the nodes of the tree. Each node has a pointer to its parent and a bit indicating whether it is a root; the root points to the designated element of the set. To provide constant-time access to the root from the designated node, the latter is either the root itself or a child of the root. With this representation, to perform unite(v, w): find the roots of the trees containing v and w, link them together by making one root the parent of the other, and make v a child of the new root if it is not that root or a child of that root already. To perform find(v): follow parent pointers until reaching a root, reach the designated element of the set in at most one more step, and return this element. A unite operation takes O(1) time. A find takes time proportional to the number of nodes on the find path. A sequence of intermixed unite and find operations thus takes O(n+s) time, where s is the total number of nodes on find paths. One way to reduce s is to use path compression: after a find, make the root the parent of every other node on the find path. Another way to reduce s is to do balanced unions. There are two well known balanced-union rules. In the first, union-by-size, each root stores the number of its descendants. To perform unite(v,w), make the root of the larger tree the parent of the root of the smaller, making either the parent of the other in case of a tie. In the second, union-by-rank, each root has a non-negative integer rank, initially zero. To perform unite(v, w), make the root of higher rank the parent of the root of lower rank; in case of a tie, make either root the parent of the other and add one to the rank of the remaining root. Both of these union rules produce balanced trees. More specifically, let F be the forest built by doing all the unite operations and none of the finds. We call F the reference forest. F is balanced, or, more precisely, c-balanced if for a constant c > 1 the number of nodes of height h in F is O(n/c h ) for every h. Both union-by-size and union-by-rank produce 2-balanced forests. Furthermore, since only roots must maintain sizes or ranks, these fields obviate the need for separate bits to indicate which nodes are roots. For any sequence of unions and finds such that the unions build a balanced forest and the finds use path compression, the total running time is O(n+mα(m+n,n)): the analysis of path compression by Tarjan 6

7 and van Leeuwen [61] applies if the reference forest is balanced. We seek a linear time bound, which we can obtain for sequences of finds that are suitably restricted. Before obtaining this bound, we discuss a more general use of path compression and balanced union: to find minima on paths in dynamic trees. 3.2 Finding Minima on Paths The dynamic path-minimum problem calls for the maintenance of a forest of rooted trees, each initially a one-node tree, whose arcs, which are directed from parent to child, have real values. The trees are subject to three operations: link(v,w,x) Nodes v and w are the roots of different trees inf, and x is a real number. Make v the parent of w by adding arc (v,w) to F, with value x. findroot(v) Return the root of the tree inf containing the node v. eval(v) Return the minimum value of an arc on the path tov from the root of the tree containing it. We shall denote byn the total number of nodes and bymthe total number of findroot and eval operations. Variants of this problem include omitting the findroot operation, replacing minimum by maximum, and requiring the eval operation to return an arc of minimum value rather than just the minimum value. The two solutions to be described are easily modified to handle these variants. We call a data structure that solves the dynamic path-minimum problem a link-eval structure. Tarjan [58] considered this problem and developed two data structures to solve it: a simple one [58, Sec. 2], which uses path compression on the forest defined by the links, and a sophisticated one [58, Sec. 5], which uses path compression on a balanced forest related to the one defined by the links. Tarjan s simple link-eval structure uses a compressed version of F, represented by parent pointers, with the nodes rather than the arcs storing values. Each root has value infinity. Perform link(v,w,x) by making v the parent of w and giving w the value x. Perform findroot(v) by following parent pointers from v to the root of the tree containing it, compressing this path, and returning the root. Perform eval(v) by following parent pointers from v to the root of the tree containing it, compressing this path, and returning the value of v. To compress a path v 0,v 1,...,v k with v i the parent of v i+1 for 0 i < k, repeat the following step for each i from 2 through k: replace the parent of v i by v 0, and replace the value of v i by the value of v i 1 if the latter is smaller. Compression preserves the results of findroot and eval operations while making tree paths shorter. If the final forest F is balanced, then this simple link-eval structure takes O(n+mα(m+n,n)) time to perform a sequence of operations [58]: the effect of a compression on the structure of a tree is the same whether the compression is due to a findroot or an eval. In our MST application the final forest is actually balanced. Our application to finding dominators requires Tarjan s sophisticated link-eval structure. 3.3 Delayed Linking with Balancing Tarjan s sophisticated structure delays the effect of some of the links so that they can be done in a way that makes the resulting forest balanced. Since our analysis requires some knowledge of the inner workings of this structure, we describe it here. We streamline the structure slightly, and we add to it the ability to do findroot operations, which were not supported by the original. We also describe (in Section 3.4) a variant that uses linking-by-rank; the original uses linking-by-size. We represent the forest F defined by the link operations by a shadow forest R. Each tree in F corresponds to a tree in R with the same vertices and the same root. Each tree T in R is partitioned into one or 7

8 more subtrees S 0,S 1,...,S k, such that the root of S i is the parent of the root of S i+1 for 0 i < k, and the root of S 0 is the root of T. We call the roots of the subtrees S 0,S 1,...,S k (including the root of S 0 ) subroots. We represent R by a set of parent pointers that are defined for nodes that are not subroots and, for each subroot, a pointer to its child that is a subroot, if any. (Each subroot has a null parent pointer; the deepest subroot has a null child pointer.) Since parents are needed only for nodes that are not subroots and child pointers are required only for subroots, we can use a single pointer per node to store both kinds of pointers, if we mark each node to indicate whether it is a subroot. We shall use shp(v) to denote the parent of v in its subtree and shc(v) to denote the child of v that is a subroot, if there is one; shp(v) = null if v is a subroot; shc(v) = null if v is a subroot without a child that is a subroot. With each node v we store a value b(v). We manipulate the trees of R and the node values to preserve two related invariants: (i) eval(v) = min{b(u) : u is an ancestor in R of v, and u is in the same subtree asv}; (ii) b(shc(v)) b(v) if shc(v) null. To help keep evaluation paths short, we use both path compression and a variant of union-by-size. We denote by size(v) the number of descendants of v in R and by subsize(v) the number of descendants of v in the same subtree as v. For convenience, we let size(null) = 0. Then subsize(v) = size(v) if v is not a subroot, and subsize(v) = size(v) size(shc(v)) if v is a subroot. We maintain sizes but only for subroots, which allows us to compute the subsize of a subroot in constant time. To initialize the structure, make each node v a singleton tree (shp(v) = shc(v) = null), with b(v) = and size(v) = 1. To perform eval(v), return b(v) if shp(v) = null; otherwise, compress the path to v from the subroot of the subtree containing it (exactly as in the simple link-eval structure of Section 3.2), and then return min{b(v), b(shp(v))}. Perform link(v, w, x) as follows. First, set b(w) (previously infinity) equal to x. Next, if size(v) size(w), perform Part 1 below; otherwise, perform Part 2 below and, if necessary, Part 3. (See Figures 1 and 2.) Part 1: (size(v) size(w).) Combine the subtree rooted at v with all the subtrees in the tree rooted at w, by setting shp(u) = v and b(u) = min{b(u),x} for each subroot u of a subtree in the tree rooted at w. Find such subroots by following shc pointers from w. (In Figure 1(Part 1), the successive values of u are w,s 1,s 2.) This step effects a compression to v from the deepest subroot descendant of w. The updates to the b-values maintain (i) and (ii). Part 2: (size(v) < size(w).) Combine all the subtrees in the tree rooted at v, by setting shp(u) = v for each subroot u v of a subtree in the tree rooted at v. (In Figure 1(Part 2), the successive values of u are r 1,r 2,r 3.) This step effects a compression to v from the deepest subroot descendant of v. Then set shc(v) = w. This may cause violations of Invariants (i) and (ii). Part 3: In order to restore (i) and (ii) after Part 2, repeat the following step until it no longer applies. Let s 0 = shc(v) and s 1 = shc(s 0 ). (In the first iteration, s 0 = w.) If s 1 null and x < b(s 1 ), compare the subsizes of s 0 and s 1. If the former is not smaller, combine the subtrees with subroots s 0 and s 1, making s 0 the new subroot, by simultaneously setting shp(s 1 ) = s 0 and shc(s 0 ) = shc(s 1 ). If the former is smaller, combine the subtrees with subroots s 0 and s 1, making s 1 the new subroot, by simultaneously setting shp(s 0 ) = s 1, shc(v) = s 1,b(s 1 ) = x, and size(s 1 ) = size(s 0 ). Once this step no longer applies, (i) and (ii) are restored. Complete the linking by setting size(v) = size(v) + size(w). We call this linking method linking-by-size. 8

9 w v v s 1 r 1 Part 1 w s 1 s 2 r 1 s 2 r 2 r 2 r 3 r 3 w v v s 1 r 1 Part 2 w r 1 r 2 r 3 s 2 r 2 s 1 r 3 s 2 Figure 1: Linking by size: Part 1, size(v) size(w), and Part 2, size(v) < size(w). v v s 0 subsize(s 0 ) subsize(s 1 ) s 0 s 1 s 2 s 1 s 2 v v s 0 subsize(s 0 ) < subsize(s 1 ) s 1 s 1 s 0 s 2 s 2 Figure 2: Linking by size: Part 3. The method must keep track of which nodes are subroots. Nodes that are not subroots can be marked as such by, e.g., setting their sizes to zero, since sizes are maintained only for subroots. We have omitted this updating from Parts 1, 2, and 3. This version of the data structure differs from the original [58] only in the placement of Part 3 of the link operation. In the original, Part 3 is done before Parts 1 and 2 to restore (i) and (ii), whether or not size(v) size(w). Delaying Part 3 allows it to be avoided entirely if size(v) size(w); in this case Part 1 alone suffices to restore (i) and (ii). This structure does not support findroot (because an eval operation reaches only a subroot, not a root), 9

10 but we can easily extend it to do so. To each subroot that is not a root, we add a pointer to its deepest subroot descendant; to each deepest subroot, we add a pointer to the root of its tree. Then a root is reachable from any subroot descendant in at most two steps. To perform findroot(v), compress the path to v from the subroot of its subtree; then follow at most two pointers to reach a root, and return this root. Operation findroot has the same asymptotic complexity as eval. The running time of a link operation increases by at most a constant factor because of the extra pointer updates needed. In the sophisticated link-eval structure, path compression is performed on the subtrees, not on the trees. The next lemma implies that these subtrees are balanced. Lemma 3.1 Consider a shadow forest built using linking-by-size. If u is a tree node such that shp(u) and shp(shp(u)) are both non-null, then subsize(shp(shp(u))) 2 subsize(u). Proof: A node u can be assigned a parent shp(u) in Part 1, 2, or 3 of a link operation. If this occurs in Part 3, subsize(shp(u)) 2 subsize(u) after u gets its parent. Once this happens, subsize(u) stays the same and subsize(shp(u)) can only increase. Thus when shp(u) gets a parent, subsize(shp(shp(u))) subsize(shp(u)) 2 subsize(u), and this inequality persists. Regardless of when u gets a parent shp(u), if shp(u) gets its parent in Part 3, then subsize(shp(shp(u))) 2 subsize(shp(u)) 2 subsize(u) when this happens, and this inequality persists. Suppose then that both u and shp(u) get their parents in Part 1 or 2. When u gets its parent, size(shp(u)) 2 subsize(u). Subsequently, size(shp(u)) cannot decrease until shp(u) gets its parent, at which time subsize(shp(shp(u))) size(shp(u)) 2 subsize(u). This inequality persists. Corollary 3.2 The subtrees in any shadow forest built using linking by size are 2-balanced. 3.4 Linking by Rank An alternative to using linking-by-size in the sophisticated link-eval structure is to use linking-by-rank. In place of a size, every node has a non-negative integer rank, initially zero. The ranks satisfy the invariant (iii) rank(shp(v)) > rank(v). We explicitly maintain ranks only for subroots. If v is a virtual tree root (i.e., in F ), we denote by maxrank(v) the maximum rank of a subroot descendant. With each virtual tree root v, we store maxrank(v) (in addition to rank(v)). Perform link(v,w,x) as follows. First, set b(w) = x. Then compare maxrank(v) to maxrank(w). We split the rest of the operation into the following parts. Part 0: If maxrank(v) = maxrank(w), set rank(v) = maxrank(v) + 1, maxrank(v) = maxrank(v) + 1, and combine all the subtrees in the trees rooted at v and w into a single subtree rooted at v, by setting shp(u) = v for each subroot u v, setting shc(v) = null, and setting b(u) = min{b(u),b(w)} if u was a descendant of w. (See Figure 3.) Part 1: If maxrank(v) > maxrank(w), set rank(v) = max{rank(v), maxrank(w) + 1}, and combine the subtree rooted at v with all the subtrees in the tree rooted at w, by setting shp(u) = v and b(u) = min{b(u), b(w)} for each subroot descendant u of w. Part 2: If maxrank(v) < maxrank(w), combine all the subtrees in the tree rooted atv into a single subtree, unless shc(v) = null, by setting rank(v) = maxrank(v) + 1, maxrank(v)=maxrank(w), and, for each subroot u v, shp(u) = v. Then set shc(v) = w. This may cause violations of Invariants (i) and (ii). 10

11 w v v s 1 r 1 Part 0 s 2 r 2 w s 1 s 2 r 1 r 2 r 3 r 3 Figure 3: Linking by rank: Part 0, maxrank(v) = maxrank(w). Part 3: To restore (i) and (ii) after Part 2, repeat the following step until it no longer applies. Let s 0 = shc(v) and s 1 = shc(s 0 ). If s 1 null and x < b(s 1 ), compare rank(s 0 ) to rank(s 1 ), and: if rank(s 0 ) = rank(s 1 ), simultaneously set shp(s 1 ) = s 0, shc(s 0 ) = shc(s 1 ), rank(s 0 ) = rank(s 0 )+1, and maxrank(v) = max{maxrank(v), rank(s 0 ) + 1}; if rank(s 0 ) > rank(s 1 ), simultaneously set shp(s 1 ) = s 0 and shc(s 0 ) = shc(s 1 ); if rank(s 0 ) < rank(s 1 ), simultaneously set shp(s 0 ) = s 1, shc(v) = s 1, and b(s 1 ) = x. Parts 1, 2, and 3 of linking-by-rank correspond to Parts 1, 2, and 3 of linking-by-size; Part 0 handles the case of equal maxranks, in which all subtrees of both trees are combined. (We could add a corresponding Part 0 to linking-by-size, but this is unnecessary.) As does linking-by-size, linking-by-rank produces balanced forests, as we now show. For a node u, let subsize(u) be the number of descendants of u in its subtree. Lemma 3.3 In any shadow forest built using linking-by-rank, any nodeuhas subsize(u) 2 (rank(u) 1)/2. Proof: To obtain this result we actually need to prove something stronger. Suppose we perform a sequence of link-by-rank operations. We track the states of nodes, their ranks, and their subsizes as the links take place. Each node is in one of two states: normal or special. The following invariants will hold: (a) a normal node u has subsize(u) 2 rank(u)/2 ; (b) a special node u has subsize(u) 2 (rank(u) 1)/2 ; (c) a special root u has a normal subroot descendant of rank at least rank(u). Initially all nodes are normal; since all initial ranks are zero, (a), (b), and (c) hold initially. We need to determine the effect of each part of an operation link(v,w,x). If maxrank(v) = maxrank(w), we make v normal after the link; all other nodes retain their states. This preserves (a), (b), and (c); the only question is whether v satisfies (a), since it gains one in rank and can change from special to normal. Before the link, both the tree rooted at v and the tree rooted at w have a subroot of rank maxrank(v). Since each of these nodes has subsize at least 2 (maxrank(v) 1)/2 before the link by (a) and (b), after the link subsize(v) 2 2 (rank(v) 2)/2 = 2 rank(v)/2. Hence (a) holds for v after the link. If maxrank(v) > maxrank(w) and rank(v) does not change as a result of the link, all nodes retain their states. The link preserves (a), (b), and (c), because no node increases in rank. If rank(v) does change because of the link (becoming one greater than the old value of maxrank(w)), we make v special. Node v 11

12 now satisfies (b), because before the link w had a normal subroot descendant u of rank maxrank(w), and subsize(u) 2 maxrank(w)/2 by (a); hence, after the link, subsize(v) 2 (rank(v) 1)/2. Node v satisfies (c), because before the link it had a normal subroot descendant z of rank maxrank(v) maxrank(w) +1, which it retains after the link. The last case is maxrank(v) < maxrank(w). In this case we look at the effects of Part 2 and Part 3 separately. If Part 2 does anything, we make v special. Node v satisfies (b), because before the link it had a normal subroot descendant of rank maxrank(v), which satisfied (a); hence, after the link, subsize(v) 2 (rank(v) 1)/2. Nodev satisfies (c) after the link, because before the linkwhad a normal subroot descendant of rank maxrank(w) maxrank(v) + 1 by (a), which becomes a normal subroot descendant of v. Finally, we must account for the effect of Part 3. Each combination of subtrees done by Part 3 preserves (a), (b), and (c), except possibly for those that combine two subtrees with subroots, say y and z, of equal rank. In this case the rank of the surviving subroot increases by one; and if the ranks of y and z previously equaled maxrank(v), maxrank(v) increases by one. To preserve the invariants in this case, we make the surviving root, say y, normal. Now y satisfies (a), because before the subtrees rooted at y and z were combined, both y and z have subsize at least 2 (rank(y) 1)/2 ; after the subtrees are combined, subsize(y) 2 2 (rank(y) 2)/2 = 2 rank(y)/2. Because y satisfies (a), v satisfies (c). Thus linking preserves the invariants. By induction, they remain true throughout any sequence of links. The lemma follows from (a) and (b). Corollary 3.4 The subtrees in any shadow forest built using linking-by-rank are 2-balanced. Theorem 3.5 A sequence of operations performed using the sophisticated link-eval structure with either linking-by-size or linking-by-rank takes O(n) time for the links and O(n + mα(m + n,n)) time for the findroot and eval operations. Proof: The time for a link is O(k + 1), where k is the decrease in the number of subtrees caused by the link. Thus the total time for all the links is O(n). The total length of compressed paths, and hence the total time for findroot and eval operations, iso(n+mα(m+n,n)) by the Tarjan-van Leeuwen analysis of path compression [61], applying Corollary 3.2 (for linking-by-size) or Corollary 3.4 (for linking-by-rank). 3.5 Refined Analysis of Path Compression In order to use path compression on balanced trees as a tool for building linear-time algorithms, we need to show that the total time becomes linear if the compressions are suitably restricted. In order to capture both DSU and link-eval applications, we abstract the situation as follows. An intermixed sequence of the following two kinds of operations is performed on a rooted forest, initially consisting ofnsingle-node trees: assign(u,v) Given two distinct roots u and v, make u the parent of v. compress(u) Compress the path to u from the root of the tree containing it, by making the root the parent of every other node on the path. Lemma 3.6 Suppose l nodes are marked and the remaining n l unmarked. Suppose the assignments build a balanced forest, and that each node has its parent change at most k times before it is in a tree containing a marked node. If there aremcompress operations, then the total number of nodes on compression paths is O(kn+mα(m+l,l)). 12

13 Proof: LetF be the balanced forest built by the entire sequence of assignments, ignoring the compressions; let c > 1 be such that F is c-balanced; and let h(v) be the height of a node v in F. Let a = log c (n/l)+log c (1/(c 1))+1. Classify each node v into one of three types: low, if v has no marked descendant in F ; middle, if v has a marked descendant in F and h(v) < a; and high otherwise. A compression path from a tree root to one of its descendants consists of zero or more high nodes followed by zero or more middle nodes followed by zero or more low nodes. Every node on the path except the first two (totaling at most 2m over all compressions) has its parent change to one of greater height as a result of the compression. Consider a compression path containing only low nodes. Since the root is low, the tree in which the compression takes place contains no marked nodes. All but two nodes on the path change parent but remain in a tree with no marked nodes. The number of times this can happen to a particular node is at most k by the hypothesis of the lemma, totaling at most kn over all compressions. Consider a compression path containing at least one middle or high node. Every low node on the path except one has its parent change from low to middle or high as a result of the compression. Thus the total number of low nodes on such paths is at most n+m. Every middle node on the path whose parent changes obtains a parent of greater height. This can happen to a middle node at most a times before its parent is high. At most one middle node on a compression path has a high parent, totaling at most m over all compression paths. Each middle node has a marked node as a descendant; each marked node has at most a +1 middle nodes as ancestors (at most one per height less than a). The total number of middle nodes is thus at most l(a + 1). Combining estimates, we find that the total number of middle nodes on compression paths is at most l a (a+1)+m. Since l n and a is O(log(n/l)), the first term is O(n), implying that the total number of middle nodes on compression paths iso(n)+m. Finally, we need to count the number of high nodes on compression paths. Since F is c-balanced, the total number of high nodes is at most i a n c i n c a c c 1 = n c a 1 (c 1) l. Let the rank of a node v be h(v) a. Then every high node has non-negative rank, and the number of high nodes of rank i 0 is at most l/c i. The analysis of Tarjan and van-leeuwen [61, Lem. 6] applied to the high nodes bounds the number of high nodes on compression paths by O(l +mα(m+l,l)). Combining all our estimates gives the lemma. Lemma 3.6 gives a bound of O(n + m) if, for example, l = O(n/loglogn), by the properties of the inverse-ackermann function [56]. In our applications l = n/log 1/3 n, which is sufficiently small to give an O(n+m) bound. We conclude this section by reviewing some previous results on disjoint set union and refined analysis of the DSU structure. The linear-time RAM DSU algorithm of Gabow and Tarjan [30] assumes a priori knowledge of the unordered set of unions. An earlier version of our work [14] contained a result much weaker than Lemma 3.6, restricted to disjoint set union, which required changing the implementation of unite based on the marked nodes. Alstrup et al. [8] also proved a weaker version of Lemma 3.6 in which the mα(m+l,l) term is replaced byllogl+m, which sufficed for their purpose. They derived this result for a hybrid algorithm that handles long paths of unary nodes outside the standard DSU structure. Dillencourt, Samet, and Tamminen [20] gave a linear-time result assuming the stable tree property: essentially, once a find is performed on any element in a set X, all subsequent finds on elements currently in X must be 13

14 performed before X can be united with another set. Fiorio and Gustedt [25] exploit the specific order of unions in an image-processing application. Gustedt [36] generalizes the previous two works to consider structures imposed on sets of allowable unions by various classes of graphs. This work is orthogonal to that of Gabow and Tarjan [30]. Other improved bounds for path compression [16, 44, 46] restrict the order in which finds are performed, in ways different from our restriction. 4 Topological Graph Computations Consider some computation that takes as input a graph G whose vertices and edges (or arcs) have O(1)- bit labels, and produces some output information (possibly none) associated with the graph itself and with each vertex and edge (or arc). We call such a computation a topological graph computation, because it is based only on the graph structure and the O(1)-bit labels, in contrast, for example, to a problem in which graph vertices and edges (or arcs) have associated real values. In general the output of a topological graph computation can be arbitrarily complex, even exponential in size, and can contain pointers to elements of the input graph. Our MST verification algorithm will exploit this flexibility; in all our other applications, the size of the output is linear in the size of the input. Suppose we need to perform a topological graph computation on not just one input graph but on an entire collection of graphs. If the input instances are small and there are many of them, then many of them will be isomorphic. By doing the computation once for each non-isomorphic instance (a canonical instance) and copying these solutions to the duplicate instances, we can amortize away the cost of actually doing the computations on the canonical instances; most of the time is spent identifying the isomorphic instances and transferring the solutions from the canonical instances to the duplicate ones. The total time spent is then linear in the total size of all the instances. Gabow and Tarjan [30] used this idea to solve a special case of disjoint set union in which the unordered set of unions is given in advance; Dixon et al. [21] applied the technique to MST verification and other problems. These applications use table look-up and require a RAM. Here we describe how to accomplish the same thing on a pointer machine. Our approach is as follows. Encode each instance as a list of pointers. Use a pointer-based radix sort to sort these lists. Identify the first instance in each group of identically-encoded instances as the canonical instance. Solve the problem for each canonical instance. Map the solutions back to the duplicate instances. The details follow. LetG be the set of input instances, each of which contains at mostg vertices. LetN be the total number of vertices and edges (or arcs) in all the instances. Let k be the maximum number of bits associated with each vertex and edge of an instance. Construct a singly linked master list whose nodes, in order, represent the integers from zero through max{g,2 k + 1} and are so numbered. For each instance G, perform a depth-first search, numbering the vertices in preorder and adding to each vertex a pointer into the master list corresponding to its preorder number; the preorder numbering allows us to maintain a global pointer into the master list to facilitate this assignment of pointers to vertices. Represent the label of each vertex and edge by a pointer into the master list, using a pointer to the zero node to encode the lack of a label. Construct a listlof triples corresponding to the vertices ofg, one triple per vertex, consisting of a pointer to the vertex, and its number and label, both represented as pointers into the master list. Construct a list Q of quadruples corresponding to the edges (or arcs) of the graph, one quadruple per edge (or arc), consisting of a pointer to the edge (or arc), and the numbers of its endpoints and its label, represented as pointers into the master list. (For an undirected graph, order the numbers of the edge endpoints in increasing order.) Encode the instance by a list whose first entry is a pair consisting of a pointer to the instance and the number of its vertices, represented as a pointer into the master list, catenated with lists L and Q. 14

15 Constructing encodings for all the instances takeso(n) time. Recall that the elements of the encodings are pointers to the master list. Attach a bucket to each element of the master list. Use a radix sort for variable length lists [1], following the encoding pointers to reach the buckets, to arrange the encodings into groups that are identical except for the first components of each list element (pair, triple, or quadruple): instances whose encodings are in the same group are isomorphic. This also takes O(N) time. Now perform the topological graph computation on any one instance of each group (the canonical instance for that group). Finally, for each duplicate instance, traverse its encoding and the encoding of the corresponding canonical instance concurrently, transferring the solution from the canonical instance to the duplicate instance. The exact form this transfer takes depends upon the form of the output to the topological graph computation. One way to do the transfer is to traverse the encodings of the canonical instance and the duplicate instance in parallel, constructing pointers between corresponding vertices and edges (or arcs) of the two instances. Then visit each vertex and edge (or arc) of the canonical instance, copying the output to the duplicate instance but replacing each pointer to a vertex or edge (or arc) by a pointer to the corresponding vertex or edge (or arc) in the duplicate instance. If the output has size linear in the input, this takes O(N) time. Summarizing, we have the following theorem. Theorem 4.1 If the output of a topological graph computation has size linear in the input size, the computation can be done on a collection of instances of total size N in O(N) time on a pointer machine, plus the time to do the computation on one instance of each group of isomorphic instances. This method extends to allow the vertices and edges (or arcs) of the instances to be labeled with integers in the range [1,g], if these labels are represented by pointers to the nodes of a precomputed master list. We shall need this extension in our applications to finding dominators and computing component trees (Sections 8 and 9, respectively). In another of our applications, MST verification, the output of the topological graph computation has exponential size: it is a comparison tree, whose nodes indicate comparisons between the weights of two edges. In this case, we do not construct a new copy of the comparison tree for each duplicate instance. Instead, when we are ready to run the comparison tree for a duplicate instance, we construct pointers from the edges of the canonical instance to the corresponding edges of the duplicate instance and run the comparison tree constructed for the canonical instance, but comparing weights of the corresponding edges in the duplicate instance. The total time is O(N) plus the time to build the comparison trees for the canonical instances plus the time to run the comparison trees for all the instances. It remains to bound the time required to do the topological graph computation on the canonical instances. The number of canonical instances is g O(g2). In all but one of our applications, the time to do a topological graph computation on an instance of size g or smaller is O(g 2 ); for MST verification, it is g O(g2). Thus the following theorem suffices for us: Theorem 4.2 If a topological graph computation takesg O(g2) time on a graph withg or fewer vertices, and if g = log 1/3 N, then the total time on a pointer machine to do the topological graph computation on a collection of graphs of total size N, each having at most g vertices, iso(n). Proof: Immediate from Theorem 4.1, since the total time to do the topological graph computation on the canonical instances isg O(g2) g O(g2) = g O(g2) = O(N). The ability to recover the answers from the topological graph computations on the instances in G is subtle yet critical. Alstrup, Secher, and Spork [9] show how to compute connectivity queries on a tree T undergoing edge deletions in linear time. They partition T into bottom-level microtrees (discussed in the next section) and compute, for each vertexv in a microtree, a bit-string that encodes the vertices on the path 15

The Level Ancestor Problem simplied

The Level Ancestor Problem simplied Theoretical Computer Science 321 (2004) 5 12 www.elsevier.com/locate/tcs The Level Ancestor Problem simplied Michael A. Bender a; ;1, Martn Farach-Colton b;2 a Department of Computer Science, State University

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

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

Lecture 5 February 26, 2007

Lecture 5 February 26, 2007 6.851: Advanced Data Structures Spring 2007 Prof. Erik Demaine Lecture 5 February 26, 2007 Scribe: Katherine Lai 1 Overview In the last lecture we discussed the link-cut tree: a dynamic tree that achieves

More information

Notes on Minimum Spanning Trees. Red Rule: Given a cycle containing no red edges, select a maximum uncolored edge on the cycle, and color it red.

Notes on Minimum Spanning Trees. Red Rule: Given a cycle containing no red edges, select a maximum uncolored edge on the cycle, and color it red. COS 521 Fall 2009 Notes on Minimum Spanning Trees 1. The Generic Greedy Algorithm The generic greedy algorithm finds a minimum spanning tree (MST) by an edge-coloring process. Initially all edges are uncolored.

More information

Planarity Algorithms via PQ-Trees (Extended Abstract)

Planarity Algorithms via PQ-Trees (Extended Abstract) Electronic Notes in Discrete Mathematics 31 (2008) 143 149 www.elsevier.com/locate/endm Planarity Algorithms via PQ-Trees (Extended Abstract) Bernhard Haeupler 1 Department of Computer Science, Princeton

More information

Hollow Heaps. Aarhus University, Denmark. Tel Aviv University, Israel. Princeton University, USA. July 7, 2015

Hollow Heaps. Aarhus University, Denmark. Tel Aviv University, Israel. Princeton University, USA. July 7, 2015 Hollow Heaps Thomas Dueholm Hansen 1 Haim Kaplan 2 Robert E. Tarjan 3 Uri Zwick 2 1 Department of Computer Science, Aarhus University, Denmark. 2 School of Computer Science, Tel Aviv University, Israel.

More information

Representations of Weighted Graphs (as Matrices) Algorithms and Data Structures: Minimum Spanning Trees. Weighted Graphs

Representations of Weighted Graphs (as Matrices) Algorithms and Data Structures: Minimum Spanning Trees. Weighted Graphs Representations of Weighted Graphs (as Matrices) A B Algorithms and Data Structures: Minimum Spanning Trees 9.0 F 1.0 6.0 5.0 6.0 G 5.0 I H 3.0 1.0 C 5.0 E 1.0 D 28th Oct, 1st & 4th Nov, 2011 ADS: lects

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

Lecture 4 Feb 21, 2007

Lecture 4 Feb 21, 2007 6.897: Advanced Data Structures Spring 2007 Prof. Erik Demaine Lecture 4 Feb 21, 2007 Scribe: Mashhood Ishaque 1 Overview In the last lecture we worked in a BST model. We discussed Wilber lower bounds

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

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

Path Minima Queries in Dynamic Weighted Trees

Path Minima Queries in Dynamic Weighted Trees Path Minima Queries in Dynamic Weighted Trees Gerth Stølting Brodal 1, Pooya Davoodi 1, S. Srinivasa Rao 2 1 MADALGO, Department of Computer Science, Aarhus University. E-mail: {gerth,pdavoodi}@cs.au.dk

More information

Minimum Spanning Trees

Minimum Spanning Trees Course Trees - the ubiquitous structure in computer science and mathematics, JASS 08 Minimum Spanning Trees Maximilian Schlund Fakultät für Informatik TU München April 20, 2008 Maximilian Schlund: Minimum

More information

Quake Heaps: A Simple Alternative to Fibonacci Heaps

Quake Heaps: A Simple Alternative to Fibonacci Heaps Quake Heaps: A Simple Alternative to Fibonacci Heaps Timothy M. Chan Cheriton School of Computer Science, University of Waterloo, Waterloo, Ontario N2L G, Canada, tmchan@uwaterloo.ca Abstract. This note

More information

Melding priority queues

Melding priority queues Melding priority queues Ran Mendelson 1, Robert E. Tarjan 2,3, Mikkel Thorup 4, and Uri Zwick 1 1 School of Computer Science, Tel Aviv University, Tel Aviv 69978, Israel 2 Department of Computer Science,

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 FAST ALGORITHM TO DETERMINE MINIMALITY OF STRONGLY CONNECTED DIGRAPHS JIANPING ZHU. (Under the Direction of Robert W. Robinson) ABSTRACT

A FAST ALGORITHM TO DETERMINE MINIMALITY OF STRONGLY CONNECTED DIGRAPHS JIANPING ZHU. (Under the Direction of Robert W. Robinson) ABSTRACT A FAST ALGORITHM TO DETERMINE MINIMALITY OF STRONGLY CONNECTED DIGRAPHS by JIANPING ZHU (Under the Direction of Robert W. Robinson) ABSTRACT In this thesis, we consider the following problem: Given a strongly

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

Optimization I : Brute force and Greedy strategy

Optimization I : Brute force and Greedy strategy Chapter 3 Optimization I : Brute force and Greedy strategy A generic definition of an optimization problem involves a set of constraints that defines a subset in some underlying space (like the Euclidean

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

3 Competitive Dynamic BSTs (January 31 and February 2)

3 Competitive Dynamic BSTs (January 31 and February 2) 3 Competitive Dynamic BSTs (January 31 and February ) In their original paper on splay trees [3], Danny Sleator and Bob Tarjan conjectured that the cost of sequence of searches in a splay tree is within

More information

The Union-Find Problem Is Linear

The Union-Find Problem Is Linear The Union-Find Problem Is Linear Hantao Zhang Computer Science Department The University of Iowa Iowa City, IA 52242 hzhang@cs.uiowa.edu Abstract The union-find problem, also known as the disjoint set

More information

RANK-PAIRING HEAPS BERNHARD HAEUPLER 1, SIDDHARTHA SEN 2,4, AND ROBERT E. TARJAN 3,4

RANK-PAIRING HEAPS BERNHARD HAEUPLER 1, SIDDHARTHA SEN 2,4, AND ROBERT E. TARJAN 3,4 RANK-PAIRING HEAPS BERNHARD HAEUPLER 1, SIDDHARTHA SEN 2,4, AND ROBERT E. TARJAN 3,4 Abstract. We introduce the rank-pairing heap, an implementation of heaps that combines the asymptotic efficiency of

More information

AMORTIZED ANALYSIS OF ALGORITHMS FOR SET UNION. union(a, B): Combine the sets named A and B into a new set, named A. WITH BACKTRACKING*

AMORTIZED ANALYSIS OF ALGORITHMS FOR SET UNION. union(a, B): Combine the sets named A and B into a new set, named A. WITH BACKTRACKING* SIAM J. COMPUT. Vol. 18, No. 1, pp. 1-11, February 1989 1989 Society for Industrial and Applied Mathematics 001 AMORTIZED ANALYSIS OF ALGORITHMS FOR SET UNION WITH BACKTRACKING* JEFFERY WESTBROOK" AND

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

Design of Data Structures for Mergeable Trees

Design of Data Structures for Mergeable Trees Design of Data Structures for Mergeable Trees Loukas Georgiadis 1, 2 Robert E. Tarjan 1, 3 Renato F. Werneck 1 Abstract Motivated by an application in computational topology, we consider a novel variant

More information

Dynamic Graph Algorithms

Dynamic Graph Algorithms Dynamic Graph Algorithms Giuseppe F. Italiano University of Rome Tor Vergata giuseppe.italiano@uniroma2.it http://www.disp.uniroma2.it/users/italiano Outline Dynamic Graph Problems Quick Intro Lecture

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

An O (mlogn)-time Algorithm for the Maximal Planar Subgraph Problem

An O (mlogn)-time Algorithm for the Maximal Planar Subgraph Problem An O (mlogn)-time Algorithm for the Maximal Planar Subgraph Problem Jiazhen Cai 1 Courant Institute, NYU New York, NY 10012 Xiaofeng Han Department of Computer Science Princeton University Princeton, NJ

More information

Properties of red-black trees

Properties of red-black trees Red-Black Trees Introduction We have seen that a binary search tree is a useful tool. I.e., if its height is h, then we can implement any basic operation on it in O(h) units of time. The problem: given

More information

Seminar on Algorithms and Data Structures: Multiple-Edge-Fault-Tolerant Approximate Shortest-Path Trees [1]

Seminar on Algorithms and Data Structures: Multiple-Edge-Fault-Tolerant Approximate Shortest-Path Trees [1] Seminar on Algorithms and Data Structures: Multiple-Edge-Fault-Tolerant Approximate Shortest-Path Trees [1] Philipp Rimle April 14, 2018 1 Introduction Given a graph with positively real-weighted undirected

More information

arxiv: v2 [cs.ds] 9 Apr 2009

arxiv: v2 [cs.ds] 9 Apr 2009 Pairing Heaps with Costless Meld arxiv:09034130v2 [csds] 9 Apr 2009 Amr Elmasry Max-Planck Institut für Informatik Saarbrücken, Germany elmasry@mpi-infmpgde Abstract Improving the structure and analysis

More information

We will show that the height of a RB tree on n vertices is approximately 2*log n. In class I presented a simple structural proof of this claim:

We will show that the height of a RB tree on n vertices is approximately 2*log n. In class I presented a simple structural proof of this claim: We have seen that the insert operation on a RB takes an amount of time proportional to the number of the levels of the tree (since the additional operations required to do any rebalancing require constant

More information

Treewidth and graph minors

Treewidth and graph minors Treewidth and graph minors Lectures 9 and 10, December 29, 2011, January 5, 2012 We shall touch upon the theory of Graph Minors by Robertson and Seymour. This theory gives a very general condition under

More information

FIBONACCI HEAPS. preliminaries insert extract the minimum decrease key bounding the rank meld and delete. Lecture slides by Kevin Wayne

FIBONACCI HEAPS. preliminaries insert extract the minimum decrease key bounding the rank meld and delete. Lecture slides by Kevin Wayne FIBONACCI HEAPS preliminaries insert extract the minimum decrease key bounding the rank meld and delete Lecture slides by Kevin Wayne http://www.cs.princeton.edu/~wayne/kleinberg-tardos Last updated on

More information

CSci 231 Final Review

CSci 231 Final Review CSci 231 Final Review Here is a list of topics for the final. Generally you are responsible for anything discussed in class (except topics that appear italicized), and anything appearing on the homeworks.

More information

Disjoint-set data structure: Union-Find. Lecture 20

Disjoint-set data structure: Union-Find. Lecture 20 Disjoint-set data structure: Union-Find Lecture 20 Disjoint-set data structure (Union-Find) Problem: Maintain a dynamic collection of pairwise-disjoint sets S = {S 1, S 2,, S r }. Each set S i has one

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

22 Elementary Graph Algorithms. There are two standard ways to represent a

22 Elementary Graph Algorithms. There are two standard ways to represent a VI Graph Algorithms Elementary Graph Algorithms Minimum Spanning Trees Single-Source Shortest Paths All-Pairs Shortest Paths 22 Elementary Graph Algorithms There are two standard ways to represent a graph

More information

On the Relationships between Zero Forcing Numbers and Certain Graph Coverings

On the Relationships between Zero Forcing Numbers and Certain Graph Coverings On the Relationships between Zero Forcing Numbers and Certain Graph Coverings Fatemeh Alinaghipour Taklimi, Shaun Fallat 1,, Karen Meagher 2 Department of Mathematics and Statistics, University of Regina,

More information

Rank-Pairing Heaps. Bernard Haeupler Siddhartha Sen Robert E. Tarjan. SIAM JOURNAL ON COMPUTING Vol. 40, No. 6 (2011), pp.

Rank-Pairing Heaps. Bernard Haeupler Siddhartha Sen Robert E. Tarjan. SIAM JOURNAL ON COMPUTING Vol. 40, No. 6 (2011), pp. Rank-Pairing Heaps Bernard Haeupler Siddhartha Sen Robert E. Tarjan Presentation by Alexander Pokluda Cheriton School of Computer Science, University of Waterloo, Canada SIAM JOURNAL ON COMPUTING Vol.

More information

CSE 100: GRAPH ALGORITHMS

CSE 100: GRAPH ALGORITHMS CSE 100: GRAPH ALGORITHMS Dijkstra s Algorithm: Questions Initialize the graph: Give all vertices a dist of INFINITY, set all done flags to false Start at s; give s dist = 0 and set prev field to -1 Enqueue

More information

Range Mode and Range Median Queries on Lists and Trees

Range Mode and Range Median Queries on Lists and Trees Range Mode and Range Median Queries on Lists and Trees Danny Krizanc 1, Pat Morin 2, and Michiel Smid 2 1 Department of Mathematics and Computer Science, Wesleyan University, Middletown, CT 06459 USA dkrizanc@wesleyan.edu

More information

Faster Algorithms for Computing Maximal 2-Connected Subgraphs in Sparse Directed Graphs

Faster Algorithms for Computing Maximal 2-Connected Subgraphs in Sparse Directed Graphs Faster Algorithms for Computing Maximal 2-Connected Subgraphs in Sparse Directed Graphs Abstract Shiri Chechik Tel Aviv University, Israel schechik@cs.tau.ac.il Giuseppe F. Italiano Università di Roma

More information

Simpler, Linear-time Transitive Orientation via Lexicographic Breadth-First Search

Simpler, Linear-time Transitive Orientation via Lexicographic Breadth-First Search Simpler, Linear-time Transitive Orientation via Lexicographic Breadth-First Search Marc Tedder University of Toronto arxiv:1503.02773v1 [cs.ds] 10 Mar 2015 Abstract Comparability graphs are the undirected

More information

Representing all Minimum Spanning Trees with Applications to Counting and Generation

Representing all Minimum Spanning Trees with Applications to Counting and Generation Representing all Minimum Spanning Trees with Applications to Counting and Generation David Eppstein Department of Information and Computer Science University of California, Irvine, CA 92717 http://www.ics.uci.edu/

More information

Algorithms for Finding Dominators in Directed Graphs

Algorithms for Finding Dominators in Directed Graphs Department of Computer Science Aarhus University Master s Thesis Algorithms for Finding Dominators in Directed Graphs Author: Henrik Knakkegaard Christensen 20082178 Supervisor: Gerth Støling Brodal January

More information

COMP 355 Advanced Algorithms

COMP 355 Advanced Algorithms COMP 355 Advanced Algorithms Algorithms for MSTs Sections 4.5 (KT) 1 Minimum Spanning Tree Minimum spanning tree. Given a connected graph G = (V, E) with realvalued edge weights c e, an MST is a subset

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

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

Lecture 20 : Trees DRAFT

Lecture 20 : Trees DRAFT CS/Math 240: Introduction to Discrete Mathematics 4/12/2011 Lecture 20 : Trees Instructor: Dieter van Melkebeek Scribe: Dalibor Zelený DRAFT Last time we discussed graphs. Today we continue this discussion,

More information

22 Elementary Graph Algorithms. There are two standard ways to represent a

22 Elementary Graph Algorithms. There are two standard ways to represent a VI Graph Algorithms Elementary Graph Algorithms Minimum Spanning Trees Single-Source Shortest Paths All-Pairs Shortest Paths 22 Elementary Graph Algorithms There are two standard ways to represent a graph

More information

Data Structure. IBPS SO (IT- Officer) Exam 2017

Data Structure. IBPS SO (IT- Officer) Exam 2017 Data Structure IBPS SO (IT- Officer) Exam 2017 Data Structure: In computer science, a data structure is a way of storing and organizing data in a computer s memory so that it can be used efficiently. Data

More information

HEAPS ON HEAPS* Downloaded 02/04/13 to Redistribution subject to SIAM license or copyright; see

HEAPS ON HEAPS* Downloaded 02/04/13 to Redistribution subject to SIAM license or copyright; see SIAM J. COMPUT. Vol. 15, No. 4, November 1986 (C) 1986 Society for Industrial and Applied Mathematics OO6 HEAPS ON HEAPS* GASTON H. GONNET" AND J. IAN MUNRO," Abstract. As part of a study of the general

More information

Maximal Monochromatic Geodesics in an Antipodal Coloring of Hypercube

Maximal Monochromatic Geodesics in an Antipodal Coloring of Hypercube Maximal Monochromatic Geodesics in an Antipodal Coloring of Hypercube Kavish Gandhi April 4, 2015 Abstract A geodesic in the hypercube is the shortest possible path between two vertices. Leader and Long

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

CS521 \ Notes for the Final Exam

CS521 \ Notes for the Final Exam CS521 \ Notes for final exam 1 Ariel Stolerman Asymptotic Notations: CS521 \ Notes for the Final Exam Notation Definition Limit Big-O ( ) Small-o ( ) Big- ( ) Small- ( ) Big- ( ) Notes: ( ) ( ) ( ) ( )

More information

Course Review for Finals. Cpt S 223 Fall 2008

Course Review for Finals. Cpt S 223 Fall 2008 Course Review for Finals Cpt S 223 Fall 2008 1 Course Overview Introduction to advanced data structures Algorithmic asymptotic analysis Programming data structures Program design based on performance i.e.,

More information

arxiv: v2 [cs.ds] 19 Feb 2015

arxiv: v2 [cs.ds] 19 Feb 2015 2-Vertex Connectivity in Directed Graphs Loukas Georgiadis 1 Giuseppe F. Italiano 2 Luigi Laura 3 Nikos Parotsidis 1 February 20, 2015 arxiv:1409.6277v2 [cs.ds] 19 Feb 2015 Abstract Given a directed graph,

More information

Matching Theory. Figure 1: Is this graph bipartite?

Matching Theory. Figure 1: Is this graph bipartite? Matching Theory 1 Introduction A matching M of a graph is a subset of E such that no two edges in M share a vertex; edges which have this property are called independent edges. A matching M is said to

More information

Graph Algorithms. Chapter 22. CPTR 430 Algorithms Graph Algorithms 1

Graph Algorithms. Chapter 22. CPTR 430 Algorithms Graph Algorithms 1 Graph Algorithms Chapter 22 CPTR 430 Algorithms Graph Algorithms Why Study Graph Algorithms? Mathematical graphs seem to be relatively specialized and abstract Why spend so much time and effort on algorithms

More information

4 Fractional Dimension of Posets from Trees

4 Fractional Dimension of Posets from Trees 57 4 Fractional Dimension of Posets from Trees In this last chapter, we switch gears a little bit, and fractionalize the dimension of posets We start with a few simple definitions to develop the language

More information

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

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 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 23529 Zhaofang Wen

More information

[13] D. Karger, \Using randomized sparsication to approximate minimum cuts" Proc. 5th Annual

[13] D. Karger, \Using randomized sparsication to approximate minimum cuts Proc. 5th Annual [12] F. Harary, \Graph Theory", Addison-Wesley, Reading, MA, 1969. [13] D. Karger, \Using randomized sparsication to approximate minimum cuts" Proc. 5th Annual ACM-SIAM Symposium on Discrete Algorithms,

More information

The strong chromatic number of a graph

The strong chromatic number of a graph The strong chromatic number of a graph Noga Alon Abstract It is shown that there is an absolute constant c with the following property: For any two graphs G 1 = (V, E 1 ) and G 2 = (V, E 2 ) on the same

More information

CSCI2100B Data Structures Trees

CSCI2100B Data Structures Trees CSCI2100B Data Structures Trees Irwin King king@cse.cuhk.edu.hk http://www.cse.cuhk.edu.hk/~king Department of Computer Science & Engineering The Chinese University of Hong Kong Introduction General Tree

More information

Are Fibonacci Heaps Optimal? Diab Abuaiadh and Jeffrey H. Kingston ABSTRACT

Are Fibonacci Heaps Optimal? Diab Abuaiadh and Jeffrey H. Kingston ABSTRACT Are Fibonacci Heaps Optimal? Diab Abuaiadh and Jeffrey H. Kingston ABSTRACT In this paper we investigate the inherent complexity of the priority queue abstract data type. We show that, under reasonable

More information

1. [1 pt] What is the solution to the recurrence T(n) = 2T(n-1) + 1, T(1) = 1

1. [1 pt] What is the solution to the recurrence T(n) = 2T(n-1) + 1, T(1) = 1 Asymptotics, Recurrence and Basic Algorithms 1. [1 pt] What is the solution to the recurrence T(n) = 2T(n-1) + 1, T(1) = 1 1. O(logn) 2. O(n) 3. O(nlogn) 4. O(n 2 ) 5. O(2 n ) 2. [1 pt] What is the solution

More information

( ) D. Θ ( ) ( ) Ο f ( n) ( ) Ω. C. T n C. Θ. B. n logn Ο

( ) D. Θ ( ) ( ) Ο f ( n) ( ) Ω. C. T n C. Θ. B. n logn Ο CSE 0 Name Test Fall 0 Multiple Choice. Write your answer to the LEFT of each problem. points each. The expected time for insertion sort for n keys is in which set? (All n! input permutations are equally

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

1 Minimum Spanning Trees: History

1 Minimum Spanning Trees: History -80: Advanced Algorithms CMU, Spring 07 Lecture #: Deterministic MSTs January, 07 Lecturer: Anupam Gupta Scribe: Anshu Bansal, C.J. Argue Minimum Spanning Trees: History The minimum spanning tree problem

More information

Algorithms for Minimum Spanning Trees

Algorithms for Minimum Spanning Trees Algorithms & Models of Computation CS/ECE, Fall Algorithms for Minimum Spanning Trees Lecture Thursday, November, Part I Algorithms for Minimum Spanning Tree Sariel Har-Peled (UIUC) CS Fall / 6 Sariel

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

Trees Rooted Trees Spanning trees and Shortest Paths. 12. Graphs and Trees 2. Aaron Tan November 2017

Trees Rooted Trees Spanning trees and Shortest Paths. 12. Graphs and Trees 2. Aaron Tan November 2017 12. Graphs and Trees 2 Aaron Tan 6 10 November 2017 1 10.5 Trees 2 Definition Definition Definition: Tree A graph is said to be circuit-free if, and only if, it has no circuits. A graph is called a tree

More information

1 Minimum Cut Problem

1 Minimum Cut Problem CS 6 Lecture 6 Min Cut and Karger s Algorithm Scribes: Peng Hui How, Virginia Williams (05) Date: November 7, 07 Anthony Kim (06), Mary Wootters (07) Adapted from Virginia Williams lecture notes Minimum

More information

Disjoint set (Union-Find)

Disjoint set (Union-Find) CS124 Lecture 6 Spring 2011 Disjoint set (Union-Find) For Kruskal s algorithm for the minimum spanning tree problem, we found that we needed a data structure for maintaining a collection of disjoint sets.

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

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

Minimal Spanning Tree

Minimal Spanning Tree Minimal Spanning Tree P. Sreenivasulu Reddy and Abduselam Mahamed Derdar Department of mathematics, Samara University Semera, Afar Regional State, Ethiopia. Post Box No.131 Abstract: In this paper authors

More information

Exact Algorithms Lecture 7: FPT Hardness and the ETH

Exact Algorithms Lecture 7: FPT Hardness and the ETH Exact Algorithms Lecture 7: FPT Hardness and the ETH February 12, 2016 Lecturer: Michael Lampis 1 Reminder: FPT algorithms Definition 1. A parameterized problem is a function from (χ, k) {0, 1} N to {0,

More information

Data Structures for Disjoint Sets

Data Structures for Disjoint Sets Data Structures for Disjoint Sets Manolis Koubarakis 1 Dynamic Sets Sets are fundamental for mathematics but also for computer science. In computer science, we usually study dynamic sets i.e., sets that

More information

Rigidity, connectivity and graph decompositions

Rigidity, connectivity and graph decompositions First Prev Next Last Rigidity, connectivity and graph decompositions Brigitte Servatius Herman Servatius Worcester Polytechnic Institute Page 1 of 100 First Prev Next Last Page 2 of 100 We say that a framework

More information

UNION FIND. naïve linking link-by-size link-by-rank path compression link-by-rank with path compression context

UNION FIND. naïve linking link-by-size link-by-rank path compression link-by-rank with path compression context UNION FIND naïve linking link-by-size link-by-rank path compression link-by-rank with path compression context Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley http://www.cs.princeton.edu/~wayne/kleinberg-tardos

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

CSE 521: Design and Analysis of Algorithms I

CSE 521: Design and Analysis of Algorithms I CSE 521: Design and Analysis of Algorithms I Greedy Algorithms Paul Beame 1 Greedy Algorithms Hard to define exactly but can give general properties Solution is built in small steps Decisions on how to

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

looking ahead to see the optimum

looking ahead to see the optimum ! Make choice based on immediate rewards rather than looking ahead to see the optimum! In many cases this is effective as the look ahead variation can require exponential time as the number of possible

More information

Advanced Set Representation Methods

Advanced Set Representation Methods Advanced Set Representation Methods AVL trees. 2-3(-4) Trees. Union-Find Set ADT DSA - lecture 4 - T.U.Cluj-Napoca - M. Joldos 1 Advanced Set Representation. AVL Trees Problem with BSTs: worst case operation

More information

For example, in the widest-shortest path heuristic [8], a path of maximum bandwidth needs to be constructed from a structure S that contains all short

For example, in the widest-shortest path heuristic [8], a path of maximum bandwidth needs to be constructed from a structure S that contains all short A Note on Practical Construction of Maximum Bandwidth Paths Navneet Malpani and Jianer Chen Λ Department of Computer Science Texas A&M University College Station, TX 77843-3112 Abstract Constructing maximum

More information

Large feedback arc sets, high minimum degree subgraphs, and long cycles in Eulerian digraphs

Large feedback arc sets, high minimum degree subgraphs, and long cycles in Eulerian digraphs Large feedback arc sets, high minimum degree subgraphs, and long cycles in Eulerian digraphs Hao Huang Jie Ma Asaf Shapira Benny Sudakov Raphael Yuster Abstract A minimum feedback arc set of a directed

More information

6.856 Randomized Algorithms

6.856 Randomized Algorithms 6.856 Randomized Algorithms David Karger Handout #4, September 21, 2002 Homework 1 Solutions Problem 1 MR 1.8. (a) The min-cut algorithm given in class works because at each step it is very unlikely (probability

More information

2 A Template for Minimum Spanning Tree Algorithms

2 A Template for Minimum Spanning Tree Algorithms CS, Lecture 5 Minimum Spanning Trees Scribe: Logan Short (05), William Chen (0), Mary Wootters (0) Date: May, 0 Introduction Today we will continue our discussion of greedy algorithms, specifically in

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

Algorithms (IX) Yijia Chen Shanghai Jiaotong University

Algorithms (IX) Yijia Chen Shanghai Jiaotong University Algorithms (IX) Yijia Chen Shanghai Jiaotong University Review of the Previous Lecture Shortest paths in the presence of negative edges Negative edges Dijkstra s algorithm works in part because the shortest

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

These are not polished as solutions, but ought to give a correct idea of solutions that work. Note that most problems have multiple good solutions.

These are not polished as solutions, but ought to give a correct idea of solutions that work. Note that most problems have multiple good solutions. CSE 591 HW Sketch Sample Solutions These are not polished as solutions, but ought to give a correct idea of solutions that work. Note that most problems have multiple good solutions. Problem 1 (a) Any

More information

Advanced Algorithms Class Notes for Monday, October 23, 2012 Min Ye, Mingfu Shao, and Bernard Moret

Advanced Algorithms Class Notes for Monday, October 23, 2012 Min Ye, Mingfu Shao, and Bernard Moret Advanced Algorithms Class Notes for Monday, October 23, 2012 Min Ye, Mingfu Shao, and Bernard Moret Greedy Algorithms (continued) The best known application where the greedy algorithm is optimal is surely

More information

logn D. Θ C. Θ n 2 ( ) ( ) f n B. nlogn Ο n2 n 2 D. Ο & % ( C. Θ # ( D. Θ n ( ) Ω f ( n)

logn D. Θ C. Θ n 2 ( ) ( ) f n B. nlogn Ο n2 n 2 D. Ο & % ( C. Θ # ( D. Θ n ( ) Ω f ( n) CSE 0 Test Your name as it appears on your UTA ID Card Fall 0 Multiple Choice:. Write the letter of your answer on the line ) to the LEFT of each problem.. CIRCLED ANSWERS DO NOT COUNT.. points each. The

More information

arxiv: v1 [cs.ds] 9 Sep 2015

arxiv: v1 [cs.ds] 9 Sep 2015 Approximating the Smallest Spanning Subgraph for 2-Edge-Connectivity in Directed Graphs Loukas Georgiadis Giuseppe F. Italiano Charis Papadopoulos Nikos Parotsidis arxiv:1509.02841v1 [cs.ds] 9 Sep 2015

More information