Content. 1 Static dictionaries. 2 Integer data structures. 3 Graph data structures. 4 Dynamization and persistence. 5 Cache-oblivious structures

Size: px
Start display at page:

Download "Content. 1 Static dictionaries. 2 Integer data structures. 3 Graph data structures. 4 Dynamization and persistence. 5 Cache-oblivious structures"

Transcription

1 Data strutures II NTIN067 Jira Fin fin/ Katedra teoreticé informatiy a matematicé logiy Matematico-fyziální faulta Univerzita Karlova v Praze Summer semester 08/9 Last change March, 09 License: Creative Commons BY-NC-SA 4.0 Jira Fin Data Structures II Jira Fin Data Structures II Jira Fin: Data Structures II General information fin@timl.mff.cuni.cz Homepage fin/ Consultations Individual schedule Jira Fin Data Structures II 3 Jira Fin Data Structures II 4 Computational model Word-RAM Static dictionaries Description A word is a w-bit integer A memory an array of words indexed by words The size of memory is w, so we assume that w = Ω(log n Operations of words in constant time: Arithmetical operations are +,,, /, mod Bit-wise operations &,,ˆ, >>, << Comparisons =, <,, >, Other operations in constant time: (unconditional jumps, assignments, memory accesses, etc. Inputs and outputs are stored in memory Notations Goal Universe U of all elements (words Store S U of size n in a data structure Using hashing, we store S in a table M = [m] = {0,..., m } of size m Create a data structure determining whether a given element of U belongs to S. Methods Build Member Search tree n log n log n optimal in the comparison model Cucoo n (exp. log n-independent FKS n (exp. -independent n log n deterministic Jira Fin Data Structures II 5 Jira Fin Data Structures II 6 Independent repeated trials Universal hashing systems Marov inequality If X is a non-negative random variable and c >, then P[X < ce[x]] > c c. Expected number of trial using probability Let V be an event that occurs in a trial with probability p. The expected number of trials to first occurrence of V in a sequence of independent trials is p. Expected number of trial using mean If X is a non-negative random variable and c >. The expected number of trials to first occurrence of X ce[x] in a sequence of independent trials is at most Example c c. If the expected number of collisions of a randomly chosen hashing function h is, then the expected number of independent trials to the first occurrence of a hashing function h with at most collisions is. c-universal hashing system A hashing system H of functions h : U M is c-universal for c > if a uniformly chosen h from H satifies P[h(x = h(y] c for every x, y U and x y. m -independent hashing system A hashing system H of functions h : U M is -independent for N if a uniformly chosen h from H satifies P[h(x i = z i for all i =,..., ] = O ( m for all pairwise different x,..., x U and all z,..., z M. Example: System Multiply-mod-prime Let p be a prime greater than U h a,b(x = (ax + b mod p mod m H = {h a,b; a, b [p], a 0} System H is -universal and -independent but it is not 3-independent Jira Fin Data Structures II 7 Jira Fin Data Structures II 8

2 Hagerup, Miltersen, Pagh, 00 [] Goal A static dictionary for n w-bit eys with constant looup time and a space consumption of O(n words can be constructed in O(n log n time on w-word-ram. The algorithm is wealy non-uniform, i.e. requires certain precomputed constants dependent on w. Overview Create a function f : [ w ] [ 4w ] which is an error-correcting code of relative minimum distance δ > 0. Create a function f : [ 4w ] [O ( n ] which is an injection on f (S Goal Find a function h : U [ r ] with U = [O ( n ] and r = max { w, 3 + log n} s.t. h is perfect on S U of size n and h can be computed in constant time and space consumption O(n for finding and storing h and h can be found in O(n log n worst case time. First, expected O(n time, then derandomize to O(n log n worst case time. 3 Create a function f 3 : [O ( n ] [O ( n ] which is an injection on f (f (S 4 Create a function f 4 : [O ( n ] [O(n] which is an injection on f 3(f (f (S f 4 f 3 f f can be computed in constant time f, f 3, f 4 can be found in time O(n log n f can be precomputed in time O(w x U is a point (α(x, β(x in a (O(n O(n-table For x U, let α(x denote the first r bits of x and β(x denotes the remaining bits. Then x (α(x, β(x is an injection (e.i. perfect on U. Jira Fin Data Structures II 9 Jira Fin Data Structures II 0 The number of remaining bits is at most r. Since r w. Definition For q 0 and functions f, g : U [ r ], the pair (f, g is q-good if f has at most q collisions and x (f (x, g(x is perfect on S. The number of collisions is the number of pairs {x, y} S such that f (x = f (y. Suppose that (f, g is q-good and r 3 + log n. Then, for every { v [ r ] there exists a v [ r ] such that (x g(x a f (x, f is q -good where q 0 if q n = n otherwise. All values a v can be computed in expected time O(n and space O(n worst case. Application: Randomized construction of a mapping [O ( n ] [O(n] 0 (α, β is ( n -good (x β(x a α(x, α =: (α, β is n-good (x β (x a α (x, α =: (α, β is 0-good, so α is perfect Jira Fin Data Structures II 0 Jira Fin Data Structures II Suppose that (f, g is q-good and r 3 + log n. Then, for every { v [ r ] there exists a v [ r ] such that (x g(x a f (x, f is q -good where q 0 if q n = n otherwise. All values a v can be computed in expected time O(n and space O(n worst case. Proof (q n Since x (f (x, g(x is perfect on S, g(x g(y. From g(x a f (x = g(x a f (y g(y a f (y it follows that h(x h(y. For every v [ r ] we randomly and independently choose a v from the uniform distribution on [ r ]. Then, h(x = h(y g(x a f (x = g(y a f (y a f (x = g(x g(y a f (y Since ([ r ], is an Abelian group, b b c is a bijection on [ r ] for every c [ r ] and so a f (y U[ r ], it follows that g(x g(y a f (y U[ r ]. Since a f (x and a f (y are independent, also a f (x and g(x g(y a f (y are independent. Hence, P[h(x = h(y] = r. 3 Use the linearity of expectation and substitute r. Let h(x = g(x a f (x If x, y S and x y and f (x = f (y, then g(x g(y and h(x h(y 3 If f (x f (y, then P[h(x = h(y] = where r av U[r ] independently for all v [ r ] 4 E[ {{x, y} S; h(x = h(y} ] ( n / r < n The expected number of trials to generate h with at most n collisions is O(. Jira Fin Data Structures II Jira Fin Data Structures II Suppose that (f, g is q-good and r 3 + log n. Then, for every { v [ r ] there exists a v [ r ] such that (x g(x a f (x, f is q -good where q 0 if q n = n otherwise. All values a v can be computed in expected time O(n and space O(n worst case. Proof (q n implies q = 0 Let S v = {x S; f (x = v} Order S v by non-increasing size, i.e. S v S v... S v r 3 For j =,..., r we find a vj such that h is perfect Note that we must find h without collisions. To be precise, we iteratively find a vj for j from to r such that it holds h(x h(y for every x S vj and y S <j where S <j = j i= Sv. i Linearity of expectation 3 Definition of S <j 4 S vi S vj 5 From this point, assume that S vj. 6 In order to verify that h has no collision, we use a counter m v = {y S <j; h(y = v}. For every j we can count the collisions and update m v in time O( S j. The expected time to find all a vj is j O( Sj = O(n. 7 For S vj = {x} we can find v with m v = 0 and set a vj = v g(x. 4 For a vj U[ r ] it holds E[ { (x, y S vj S <j; h(x = h(y } ] S vj S <j P[h(x = h(y] j i= Sv j Sv i /r 3 j i= S v i / r 4 j ( Svi i= / r 5 q/ r 5 The expected number of trials to generate a vj such that h has no collision is O(. 6 7 Jira Fin Data Structures II 3 Jira Fin Data Structures II 3

3 Derandomization Let L (a = { (x, y S vj S <j; (g(x a [] = (h(y [] } (a i denotes the i-th bit of a and (a M denotes the vector of all bits (a i for i M [r] for j to r do a vj 0 3 for 0 to r do 4 if L +(a vj > L +(a vj + then 5 a vj a vj + Where [r] and a [ ] Our goal is to iteratively and deterministically compute a vj for j from to r. The value of a v is computed by bits from the least significant to the most significant bit. L (a determines the number of collision between S vj and S <j if we consider only last bits. Proof (goodness of (h, f L (a + L (a = L (a for every a [ ] and [r] L (a vj L (av j L 0(av j = Sv j S <j The total number of collision is at most j Lr (av j j r S vj S <j i<j r S vj S vi ( r i Sv < n i 6 If q n, then the number of collision with S vj is L r (a vj i<j r S vj S vi ( i<j r Sv j r q Jira Fin Data Structures II 4 Jira Fin Data Structures II 4 Derandomization Let L (a = { (x, y S vj S <j; (g(x a [] = (h(y [] } (a i denotes the i-th bit of a and (a M denotes the vector of all bits (a i for i M [r] for j to r do a vj 0 3 for 0 to r do 4 if L +(a vj > L +(a vj + then 5 a vj a vj + Proof (Complexity In order to compute L (a, we build a binary tree (trie Every vertex a [ ] of the -th level has a counter c (a = { y S <j; (h(y [] = (a [] } L (a = x Sv j c (g(x a can be computed in O ( S vj time After the j-th step, counters can be updated in O ( S vj r time Total time is j Sv r = O(n log n j Static dictionaries: [O ( n ] [O ( n ] Approach Every x U = [O ( n ] can be regarded as constant-length string over an alphabet of size n Build n-way branching compressed trie of string S The number of leaves is S = n, so the total number of vertices is at most n Build static [O ( n ] [O(n] dictionary for pairs (vertex of the trie, letter which returns a child of the vertex One polynomial-size-universe looup is evaluated using a constant number of quadratic-size-universe looups Space complexity is O(n and this dictionary is constructed in O(n log n time Jira Fin Data Structures II 5 Jira Fin Data Structures II 6 Static dictionaries: Error-correcting code Definition The Hamming distance between x [ w ] and y [ w ] is the number of bits in which x and y differ. ψ : [ w ] [ 4w ] is an error correcting code of relative minimum distance δ > 0 if the Hamming distance between ψ(x and ψ(y is at least 4wδ for every distinct x, y [ w ]. For δ < it holds that 4wδ < and the identity is an error correcting code of 4w relative minimum distance δ. The number of y [ 4w ] within Hamming distance from a fixed x [ 4w ] is ( 4w i=0 i ( 4w ( 4w i=0 i ( 4w i ( 4w ( + 4w 4w ( 4w e ( 4ew using the binomial theorem. 3 By setting = 4wδ we obtain w 4w ( 4ew w ( 4ew 4wδ 4wδ = ( ( e δ 4δ w Let H be a -universal hashing system of function [ w ] [ 4w ]. For every δ with /4w < δ /, the probability that h U(H is an error correcting code of relative minimum distance δ > 0 is at least ( ( e δ 4δ /4 w. Proof For x [ 4w ] the number of y within Hamming distance is at most ( 4ew. For x y, P(Hamming distance between x and y 4w ( 4ew The probability that this happens for any of the ( w < w pairs is at most ( ( e δ 4δ /4 w 3 Jira Fin Data Structures II 7 Jira Fin Data Structures II 7 Static dictionaries: [ w ] [O ( n ] Let ψ : [ w ] [ 4w ] be an error correcting code of relative minimum distance δ > 0 and S U = [ w ] of size n. There exists a set D [4w] with D log n/ log δ such that for every pair x, y of distinct elements of S it holds (ψ(x D (ψ(y D. Proof Note that for every D [4w] the set S is split into D disjoint clusters C(D, v for v [ D ]. For i = 0 it holds that D 0 = and B(D 0 = ( n < n 3 A bit d [4w] \ D i with I(d ( δ B(D i can be found in O(wn time as follows. We a list of all clusters C(D i, v of size at least two. Every cluster has a list of all elements. So, I(d for one d [4w] \ D i can be determined in O(n time and we can process all d in O(wn time. Then, all lists can be updated in O(n time. Using word-level parallelism, the time complexity can be improved to O(n.. For D [4w] and v [ D ] let C(D, v = {x S; (ψ(x D = v} The set of colliding pairs of D is B(D = v [ D ] ( C(D,v We construct D 0 D... D such that D i = i and B(D i < ( δ i n / Let I(d = {{x, y} B(D i; (ψ(x d = (ψ(y d} be the colliding pairs indistinguishable by d [4w] \ D i Let I = d [4w]\D i I(d Every pair {x, y} B(D i contributes to I by at most 4w i 4wδ < 4w( δ, so I 4w( δ B(D i By averaging, there exists d [4w] \ D i such that I(d I ( δ B(D 4w i i 3 Let D i+ = D i {d}. Hence, B(D i+ = I(d ( δ B(D i By setting = log n/ log we obtain B(D δ <. Jira Fin Data Structures II 8 Jira Fin Data Structures II 8

4 Word- Theorem (Linear compression and speed up An algorithm running on a O(w-word-RAM with time complexity T (n and space complexity S(n can be simulated on w-word-ram with time complexity O(T (n and space complexity O(S(n assuming S(n = o( w. Proof Every word of O(w-word-RAM is replaced by O( words on w-word-ram, so the space complexity is O(T (n. Every instruction on O(w-word-RAM is replaced by O( instruction on w-word-ram. 3 Jira Fin Data Structures II 9 Jira Fin Data Structures II 0 This theorem is similar to the linear speed theorem for Turing machines. The assumption S(n = o( w is needed to ensure a sufficient amount of memory for linear data decompression. 3 Bit-wise operations and comparisons are trivial. In order to simulate arithmetical operations, every O(w bits word is split into w bits words to handle integer overflows and carry. RAM with uninitialized memory Theorem Every program with time complexity T (n and space complexity S(n which assumes initialized memory by zeros can be simulated by a program with time complexity O(T (n and space complexity S(n which do not assume initialized memory. Proof Simulation uses the following variables: M: An array of the original memory N: The number of already initialized cells by the original program I: An array of indices of all initialized cells X: A reverse table of I, i.e. if j is initialized, then I[X[j]] = j A read cell j is initialized if and only if X[j] < N and I[X[j]] = j. Jira Fin Data Structures II 0 Jira Fin Data Structures II Reading initialized memory must be permitted but an arbitrary value can be read. Integer data structures Goal Create a dynamic data structure storing a set S of intergers from a universe U with is can find the predecessor and the successor of a element x U. Predecessor: PRED(x U = max {y S; y < x} Successor SUCC(x U = min {y S; y > x} An invalid element is returned if no such element exists. Our nowledge O(log n query and update using search trees Jira Fin Data Structures II Jira Fin Data Structures II van Emde Boas tree [3] Notation For a t-bit integer x U let r(x be the left (upper t/ bits of x and l(x be the left (lower t/ bits of x. For a set of elements S let S i = {r(x S \ min S; l(x = i} for i l(u P = {S i; S i } A node of van Emde Boas tree contains Pointers to the minimum and maximum of S An array of veb trees for all sets S i A primary veb tree of elements P for finding non-empty bucets Space complexity Terrible: O(U, but we will improve it later. Requires initialized memory van Emde Boas tree: Operation FIND(x Algorithm Procedure FI N D(x, S if S = then 3 return None 4 if x = min(s then 5 return min(s 6 return FI N D(r(x, S l(x Analysis The height of the tree is O(log log U Time complexity is O(log log U Jira Fin Data Structures II 3 Jira Fin Data Structures II 4

5 van Emde Boas tree: Operation SUCC(x Algorithm Procedure SU C C(x, S if S = or x max(s then 3 return None 4 if x < min(s then 5 return min(s 6 i l(x 7 if S i and x < max(s i then 8 return SU C C(r(x, S i 9 i SU C C(i, P 0 return min(s i van Emde Boas tree: Operation INSERT(x Algorithm Procedure IN S E R T(x, S if S = then 3 min(s max(s x and return 4 if x < min(s then 5 swap(x, min(s 6 if x > max(s then 7 max(s x 8 i l(x 9 if S i = then 0 IN S E R T(i, P IN S E R T(r(x, S i Analysis The recursion is called at most once for every level of the tree Time complexity is O(log log U Analysis If S i =, then IN S E R T(r(x, S i only sets min(s i and max(s i A non-trivial recursion is called at most once for every level of the tree Time complexity is O(log log U Jira Fin Data Structures II 5 Jira Fin Data Structures II 6 van Emde Boas tree: Operation DELETE(x Algorithm Time complexity is also O(log log U Function DELETEMIN also returns the new minimal value. Procedure DE L E T E(x, S if S = or x = min(s = max(s then 3 S and return 4 if x = min(s then 5 min(s DE L E T EMI N(S and return 6 i l(x 7 if x = min(s i = max(s i then 8 DE L E T E(i, P 9 DE L E T E(r(x, S i 0 max(s max(s max(p Procedure DE L E T EMI N(S i min(p 3 if min(s i < max(s i then 4 return DE L E T EMI N(S i 5 S i 6 i DE L E T EMI N(P 7 return min(s i Jira Fin Data Structures II 7 Jira Fin Data Structures II 7 x-fast trie (Willard [4] First step A set S is represented using an array A such that x is stored at A[x] Non-empty positions of A are interconnected using a lined list Build a binary tree T whose leaves are cells of A Every node v of T stores the minimum and maximum of the subtree of v Operation SUCC(x If A[x] is non-empty, then return A[x] next Find the largest empty subtree v containing x and its parent p If v is a left child of p, then return p min Return p max next Complexity Space: O(U SUCC: O(log U INSERT, DELETE: O(log U x-fast trie: Improvements Second step: Speed up The largest empty subtree v containing x can be found using binary search Time complexity of SUCCis O(log log U Third step: Space reduction The number of nodes of T with non-empty subtree is at most nw Store them in a hash table (e.g. Cucoo x-fast trie Space complexity O(nw SUCC: O(log log U worst case INSERT, DELETE: O(log U expected amortized Jira Fin Data Structures II 8 Jira Fin Data Structures II 9 y-fast trie (Willard [4] y-fast trie: Operations FIND and SUCC Structure Split the ordered set S into Θ(n/B blocs S i of size Θ(B where B = log U For every bloc S i choose a representative r i and let R be the set of all representatives Create x-fast trie for representatives R, called a primary tree For every bloc S i, create a balanced search tree T i, called bloc trees Space complexity Every elements of S is stored in one node of one bloc tree Space complexity of al bloc trees is O(n Space complexity of the primary tree is O( R w = O(n since R = Θ(n/ log U and w = Θ(log U Operation FIND(x Find the predecessor r i and the successor r j representatives of x in the primary tree Element x lives in T i or T j, so search both bloc trees Time complexity Representative are found in time O(log log U Searching bloc trees taes O(log B = O(log log U Time complexity of operation FINDis O(log log U Operation SUCC(x If x / S, then FIND(x finds both the predecessor and the successor of x If x S, we use a lined list to find the successor Time complexity of operation SUCCis O(log log U Jira Fin Data Structures II 30 Jira Fin Data Structures II 3

6 If x is a representative, we search only one tree. y-fast trie: Operations INSERT and DELETE Without balancing sizes of blocs Find the proper bloc tree: O(log log U time Update the bloc tree: O(log B = O(log log U time However, the size of blocs must be O(log B and number of blocs must be O(n/ log B Balancing sizes of blocs If a bloc is too large, split it If a bloc is too small, merge it with a sibling or move Ω(B elements from a sibling Updates blocs trees taes O(B time Updates the primary tree taes O(log U time Homewor: Create rules which ensures that balancing occur once every Ω(B updates Amortized cost of balancing is O( Time complexity is O(log log U expected amortized Jira Fin Data Structures II 3 Jira Fin Data Structures II 3 Remind that x-fast trie uses Cucoo hashing Representation of a vector Consider b-bits integers x 0,..., x n Every integers is prepended by 0 and concatenated, i.e. a vector is represented as n i=0 xii(b+ Using linear compression theorem, it suffices to assume that nb = O(w Operation Read(x,i Returns the i-th integers from a vector x Read(x,i = x >> i(b+ & b where b is a binary number with b ones, i.e. b+ Operation Read(x,i,a Write b into the i-th position of x Write(x,i,a = (x&m i (a << i(b+ where M i = (b+(n i 0 b+ (b+i is a mas cleaning the i-th position Jira Fin Data Structures II 3 Jira Fin Data Structures II 33 Replicate(a Sum(x Create n copies of a Replicate(a = a (0 b Return the sum n i=0 xi Sum(x = x mod b+ x = n i=0 xib+ n i=0 xi mod b+ Ran(x,a The number of elements of x smaller than a Ran(x,a = Sum(x,Cmp(Replicate(a Cmp(x,y return z such that z i = if x i y i and 0 otherwise in the difference (x i (0y i, the first bit is if and only if x i y i Cmp(x,y = (((x (0 b n y >> b&(0 b n Min(x,y m = Cmp(x, y b Insert(x,a Insert a into a sorted vector x i = Ran(x,a is the possition for a in x Filter and move x i,..., x n to left m filters positions of x where x i y i Min(x,y = (x& m (y&m Jira Fin Data Structures II 34 Jira Fin Data Structures II 35 assuming w Ω(b Weight(a Unpac(a Create a vector x such that x i equals to the i-th bit a i of a y = Replicate(a &( b,...,, i.e. y i = i a i Unpac(a = Cmp(y, (0 b n Unpac π(a according to to a permutation π The Hamming weight of a Weight(a = Sum(Unpac(a Permute π (a Permute bits in a according to a permutation π Permute π(a = Pac(Unpac π(a Pac(a Consider that b is decreased by one and apply Sum Since the vector is not properly formatted, modulo cannot be used Pac(a = ((a (0 b n >> bn& b LSB(a The least significant bit in a LSB(a = Weight(a (a - MSB(a MSB(a = b--lsb(permute revers(a Jira Fin Data Structures II 36 Jira Fin Data Structures II 37

7 Fusion trees (Fredman, Willard, 993 [] MSB(a on O(w bits b = w Split a into l bloc of b bits and padding x = (a&(0 b l ((a&(0 b l >> b Now, padding is zero and x i = 0 if and only if i-th bloc is zero y = Cmp(x, y i = if if and only if i-th bloc is non-zero j = MSB(Pac(y j is the first non-empty bloc z = (a >> (b + j& b+ z is the content of the j-th bloc MSB(a = (b + j+ MSB(z Fusion node Let = O (w /5 A fusion node stores eys x 0,..., x A fusion node can find Ran, SUCC and PRED in O( Construction time is Poly( Fusion tree B-tree for B = Nodes are Fusion nodes The depth of the tree is O(log B (n = O ( log n log w Time complexity of Ran, SUCC and PRED is O ( log n log w Jira Fin Data Structures II 38 Jira Fin Data Structures II 39 Fusion trees Fusion node Splitting node is a node of degree. We call them splitting levels. 3 Note that every level of a BST correspond to one bit in the binary code. Bits corresponding to splitting levels are called splitting bits. Since only splitting bits are significant, s(x select these splitting bits from x. Consider a binary search tree (BST on eys x 0,..., x The number of leaves is, so the number of splitting nodes is Hence, at most levels has a splitting node Let s(x select all splitting bits from the binary code of x 3 Observe that s(x 0 < s(x < < s(x S = (s(x 0,..., s(x The number of bits of S is at most = O (w /5 so S can be stored in a single w-word Ran(x can be computed using Ran(s(x,S in O( However, we need to compute s(x in O( We find a(x of length O ( 4 containing s(x with extra zeros on the same position of all x Jira Fin Data Structures II 40 Jira Fin Data Structures II 40 Fusion trees For every b 0 < < b there exist m 0 < < m such that b i + m j are pair-wise different for all i and j b 0 + m 0 < < b + m (b + m (b 0 + m 0 = O ( 4 Splitting bits with extra zeros y = x& i b i filters all splitting bits j xb i b i +m j z = y j m j = i There is no carry since b i + m j are pair-wise different a(x = z&( i b i +m i >> (b 0 + m 0 Jira Fin Data Structures II 4 Jira Fin Data Structures II 4 Jira Fin Data Structures II 43 Jira Fin Data Structures II 44

8 Jira Fin Data Structures II 45 Jira Fin Data Structures II 46 [] Michael L Fredman and Dan E Willard. Surpassing the information theoretic bound with fusion trees. Journal of computer and system sciences, 47(3:44 436, 993. [] Torben Hagerup, Peter Bro Miltersen, and Rasmus Pagh. Deterministic dictionaries. Journal of Algorithms, 4(:69 85, 00. [3] Peter van Emde Boas. Preserving order in a forest in less than logarithmic time. In 6th Annual Symposium on Foundations of Computer Science (sfcs 975, pages IEEE, 975. [4] Dan E Willard. Log-logarithmic worst-case range queries are possible in space θ (n. Information Processing Letters, 7(:8 84, 983. Jira Fin Data Structures II 47 Jira Fin Data Structures II 47

Advanced Data Structures

Advanced Data Structures Simon Gog gog@kit.edu - Simon Gog: KIT The Research University in the Helmholtz Association www.kit.edu Predecessor data structures We want to support the following operations on a set of integers from

More information

Advanced Data Structures

Advanced Data Structures Simon Gog gog@kit.edu - Simon Gog: KIT University of the State of Baden-Wuerttemberg and National Research Center of the Helmholtz Association www.kit.edu Predecessor data structures We want to support

More information

Lecture 2 September 4, 2014

Lecture 2 September 4, 2014 CS 224: Advanced Algorithms Fall 2014 Prof. Jelani Nelson Lecture 2 September 4, 2014 Scribe: David Liu 1 Overview In the last lecture we introduced the word RAM model and covered veb trees to solve the

More information

lsb(x) = Least Significant Bit?

lsb(x) = Least Significant Bit? lsb(x) = Least Significant Bit? w-1 lsb i 1 0 x 0 0 1 0 1 0 1 1 0 0 1 0 0 0 0 0 1 msb(x) in O(1) steps using 5 multiplications [M.L. Fredman, D.E. Willard, Surpassing the information-theoretic bound with

More information

Problem 1: (Chernoff Bounds via Negative Dependence - from MU Ex 5.15)

Problem 1: (Chernoff Bounds via Negative Dependence - from MU Ex 5.15) Problem 1: Chernoff Bounds via Negative Dependence - from MU Ex 5.15) While deriving lower bounds on the load of the maximum loaded bin when n balls are thrown in n bins, we saw the use of negative dependence.

More information

Dynamic Ordered Sets with Exponential Search Trees

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

More information

CSE 190, Great ideas in algorithms: Pairwise independent hash functions

CSE 190, Great ideas in algorithms: Pairwise independent hash functions CSE 190, Great ideas in algorithms: Pairwise independent hash functions 1 Hash functions The goal of hash functions is to map elements from a large domain to a small one. Typically, to obtain the required

More information

1 Probability Review. CS 124 Section #8 Hashing, Skip Lists 3/20/17. Expectation (weighted average): the expectation of a random quantity X is:

1 Probability Review. CS 124 Section #8 Hashing, Skip Lists 3/20/17. Expectation (weighted average): the expectation of a random quantity X is: CS 24 Section #8 Hashing, Skip Lists 3/20/7 Probability Review Expectation (weighted average): the expectation of a random quantity X is: x= x P (X = x) For each value x that X can take on, we look at

More information

Lecture 5: Hashing. David Woodruff Carnegie Mellon University

Lecture 5: Hashing. David Woodruff Carnegie Mellon University Lecture 5: Hashing David Woodruff Carnegie Mellon University Hashing Universal hashing Perfect hashing Maintaining a Dictionary Let U be a universe of keys U could be all strings of ASCII characters of

More information

Lecture 4: Divide and Conquer: van Emde Boas Trees

Lecture 4: Divide and Conquer: van Emde Boas Trees Lecture 4: Divide and Conquer: van Emde Boas Trees Series of Improved Data Structures Insert, Successor Delete Space This lecture is based on personal communication with Michael Bender, 001. Goal We want

More information

Optimal Color Range Reporting in One Dimension

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

More information

10 van Emde Boas Trees

10 van Emde Boas Trees Dynamic Set Data Structure S: S. insert(x) S. delete(x) S. search(x) S. min() S. max() S. succ(x) S. pred(x) Ernst Mayr, Harald Räcke 389 For this chapter we ignore the problem of storing satellite data:

More information

So far we have implemented the search for a key by carefully choosing split-elements.

So far we have implemented the search for a key by carefully choosing split-elements. 7.7 Hashing Dictionary: S. insert(x): Insert an element x. S. delete(x): Delete the element pointed to by x. S. search(k): Return a pointer to an element e with key[e] = k in S if it exists; otherwise

More information

Hash tables. Hash tables

Hash tables. Hash tables Dictionary Definition A dictionary is a data-structure that stores a set of elements where each element has a unique key, and supports the following operations: Search(S, k) Return the element whose key

More information

Integer Sorting on the word-ram

Integer Sorting on the word-ram Integer Sorting on the word-rm Uri Zwick Tel viv University May 2015 Last updated: June 30, 2015 Integer sorting Memory is composed of w-bit words. rithmetical, logical and shift operations on w-bit words

More information

Cache-Oblivious Hashing

Cache-Oblivious Hashing Cache-Oblivious Hashing Zhewei Wei Hong Kong University of Science & Technology Joint work with Rasmus Pagh, Ke Yi and Qin Zhang Dictionary Problem Store a subset S of the Universe U. Lookup: Does x belong

More information

Hash tables. Hash tables

Hash tables. Hash tables Dictionary Definition A dictionary is a data-structure that stores a set of elements where each element has a unique key, and supports the following operations: Search(S, k) Return the element whose key

More information

12 Hash Tables Introduction Chaining. Lecture 12: Hash Tables [Fa 10]

12 Hash Tables Introduction Chaining. Lecture 12: Hash Tables [Fa 10] Calvin: There! I finished our secret code! Hobbes: Let s see. Calvin: I assigned each letter a totally random number, so the code will be hard to crack. For letter A, you write 3,004,572,688. B is 28,731,569½.

More information

Analysis of Algorithms I: Perfect Hashing

Analysis of Algorithms I: Perfect Hashing Analysis of Algorithms I: Perfect Hashing Xi Chen Columbia University Goal: Let U = {0, 1,..., p 1} be a huge universe set. Given a static subset V U of n keys (here static means we will never change the

More information

compare to comparison and pointer based sorting, binary trees

compare to comparison and pointer based sorting, binary trees Admin Hashing Dictionaries Model Operations. makeset, insert, delete, find keys are integers in M = {1,..., m} (so assume machine word size, or unit time, is log m) can store in array of size M using power:

More information

Hashing. Dictionaries Chained Hashing Universal Hashing Static Dictionaries and Perfect Hashing. Philip Bille

Hashing. Dictionaries Chained Hashing Universal Hashing Static Dictionaries and Perfect Hashing. Philip Bille Hashing Dictionaries Chained Hashing Universal Hashing Static Dictionaries and Perfect Hashing Philip Bille Hashing Dictionaries Chained Hashing Universal Hashing Static Dictionaries and Perfect Hashing

More information

Lecture Lecture 3 Tuesday Sep 09, 2014

Lecture Lecture 3 Tuesday Sep 09, 2014 CS 4: Advanced Algorithms Fall 04 Lecture Lecture 3 Tuesday Sep 09, 04 Prof. Jelani Nelson Scribe: Thibaut Horel Overview In the previous lecture we finished covering data structures for the predecessor

More information

Hashing. Hashing. Dictionaries. Dictionaries. Dictionaries Chained Hashing Universal Hashing Static Dictionaries and Perfect Hashing

Hashing. Hashing. Dictionaries. Dictionaries. Dictionaries Chained Hashing Universal Hashing Static Dictionaries and Perfect Hashing Philip Bille Dictionaries Dictionary problem. Maintain a set S U = {,..., u-} supporting lookup(x): return true if x S and false otherwise. insert(x): set S = S {x} delete(x): set S = S - {x} Dictionaries

More information

Hash tables. Hash tables

Hash tables. Hash tables Basic Probability Theory Two events A, B are independent if Conditional probability: Pr[A B] = Pr[A] Pr[B] Pr[A B] = Pr[A B] Pr[B] The expectation of a (discrete) random variable X is E[X ] = k k Pr[X

More information

Notes on Logarithmic Lower Bounds in the Cell Probe Model

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

More information

On Adaptive Integer Sorting

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

More information

Optimal Bounds for the Predecessor Problem and Related Problems

Optimal Bounds for the Predecessor Problem and Related Problems Optimal Bounds for the Predecessor Problem and Related Problems Paul Beame Computer Science and Engineering University of Washington Seattle, WA, USA 98195-2350 beame@cs.washington.edu Faith E. Fich Department

More information

Searching. Constant time access. Hash function. Use an array? Better hash function? Hash function 4/18/2013. Chapter 9

Searching. Constant time access. Hash function. Use an array? Better hash function? Hash function 4/18/2013. Chapter 9 Constant time access Searching Chapter 9 Linear search Θ(n) OK Binary search Θ(log n) Better Can we achieve Θ(1) search time? CPTR 318 1 2 Use an array? Use random access on a key such as a string? Hash

More information

1 Maintaining a Dictionary

1 Maintaining a Dictionary 15-451/651: Design & Analysis of Algorithms February 1, 2016 Lecture #7: Hashing last changed: January 29, 2016 Hashing is a great practical tool, with an interesting and subtle theory too. In addition

More information

Lecture 4 Thursday Sep 11, 2014

Lecture 4 Thursday Sep 11, 2014 CS 224: Advanced Algorithms Fall 2014 Lecture 4 Thursday Sep 11, 2014 Prof. Jelani Nelson Scribe: Marco Gentili 1 Overview Today we re going to talk about: 1. linear probing (show with 5-wise independence)

More information

Advanced Implementations of Tables: Balanced Search Trees and Hashing

Advanced Implementations of Tables: Balanced Search Trees and Hashing Advanced Implementations of Tables: Balanced Search Trees and Hashing Balanced Search Trees Binary search tree operations such as insert, delete, retrieve, etc. depend on the length of the path to the

More information

Lecture: Analysis of Algorithms (CS )

Lecture: Analysis of Algorithms (CS ) Lecture: Analysis of Algorithms (CS483-001) Amarda Shehu Spring 2017 1 Outline of Today s Class 2 Choosing Hash Functions Universal Universality Theorem Constructing a Set of Universal Hash Functions Perfect

More information

Algorithms lecture notes 1. Hashing, and Universal Hash functions

Algorithms lecture notes 1. Hashing, and Universal Hash functions Algorithms lecture notes 1 Hashing, and Universal Hash functions Algorithms lecture notes 2 Can we maintain a dictionary with O(1) per operation? Not in the deterministic sense. But in expectation, yes.

More information

14.1 Finding frequent elements in stream

14.1 Finding frequent elements in stream Chapter 14 Streaming Data Model 14.1 Finding frequent elements in stream A very useful statistics for many applications is to keep track of elements that occur more frequently. It can come in many flavours

More information

Data Structure. Mohsen Arab. January 13, Yazd University. Mohsen Arab (Yazd University ) Data Structure January 13, / 86

Data Structure. Mohsen Arab. January 13, Yazd University. Mohsen Arab (Yazd University ) Data Structure January 13, / 86 Data Structure Mohsen Arab Yazd University January 13, 2015 Mohsen Arab (Yazd University ) Data Structure January 13, 2015 1 / 86 Table of Content Binary Search Tree Treaps Skip Lists Hash Tables Mohsen

More information

Quiz 1 Solutions. (a) f 1 (n) = 8 n, f 2 (n) = , f 3 (n) = ( 3) lg n. f 2 (n), f 1 (n), f 3 (n) Solution: (b)

Quiz 1 Solutions. (a) f 1 (n) = 8 n, f 2 (n) = , f 3 (n) = ( 3) lg n. f 2 (n), f 1 (n), f 3 (n) Solution: (b) Introduction to Algorithms October 14, 2009 Massachusetts Institute of Technology 6.006 Spring 2009 Professors Srini Devadas and Constantinos (Costis) Daskalakis Quiz 1 Solutions Quiz 1 Solutions Problem

More information

arxiv: v1 [cs.ds] 15 Feb 2012

arxiv: v1 [cs.ds] 15 Feb 2012 Linear-Space Substring Range Counting over Polylogarithmic Alphabets Travis Gagie 1 and Pawe l Gawrychowski 2 1 Aalto University, Finland travis.gagie@aalto.fi 2 Max Planck Institute, Germany gawry@cs.uni.wroc.pl

More information

CS 591, Lecture 6 Data Analytics: Theory and Applications Boston University

CS 591, Lecture 6 Data Analytics: Theory and Applications Boston University CS 591, Lecture 6 Data Analytics: Theory and Applications Boston University Babis Tsourakakis February 8th, 2017 Universal hash family Notation: Universe U = {0,..., u 1}, index space M = {0,..., m 1},

More information

Assignment 5: Solutions

Assignment 5: Solutions Comp 21: Algorithms and Data Structures Assignment : Solutions 1. Heaps. (a) First we remove the minimum key 1 (which we know is located at the root of the heap). We then replace it by the key in the position

More information

Algorithm Design CS 515 Fall 2015 Sample Final Exam Solutions

Algorithm Design CS 515 Fall 2015 Sample Final Exam Solutions Algorithm Design CS 515 Fall 2015 Sample Final Exam Solutions Copyright c 2015 Andrew Klapper. All rights reserved. 1. For the functions satisfying the following three recurrences, determine which is the

More information

Introduction to Hash Tables

Introduction to Hash Tables Introduction to Hash Tables Hash Functions A hash table represents a simple but efficient way of storing, finding, and removing elements. In general, a hash table is represented by an array of cells. In

More information

Data Structures and Algorithms " Search Trees!!

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

More information

1 Hashing. 1.1 Perfect Hashing

1 Hashing. 1.1 Perfect Hashing 1 Hashing Hashing is covered by undergraduate courses like Algo I. However, there is much more to say on this topic. Here, we focus on two selected topics: perfect hashing and cockoo hashing. In general,

More information

Problem. Maintain the above set so as to support certain

Problem. Maintain the above set so as to support certain Randomized Data Structures Roussos Ioannis Fundamental Data-structuring Problem Collection {S 1,S 2, } of sets of items. Each item i is an arbitrary record, indexed by a key k(i). Each k(i) is drawn from

More information

Hash Tables. Given a set of possible keys U, such that U = u and a table of m entries, a Hash function h is a

Hash Tables. Given a set of possible keys U, such that U = u and a table of m entries, a Hash function h is a Hash Tables Given a set of possible keys U, such that U = u and a table of m entries, a Hash function h is a mapping from U to M = {1,..., m}. A collision occurs when two hashed elements have h(x) =h(y).

More information

Insert Sorted List Insert as the Last element (the First element?) Delete Chaining. 2 Slide courtesy of Dr. Sang-Eon Park

Insert Sorted List Insert as the Last element (the First element?) Delete Chaining. 2 Slide courtesy of Dr. Sang-Eon Park 1617 Preview Data Structure Review COSC COSC Data Structure Review Linked Lists Stacks Queues Linked Lists Singly Linked List Doubly Linked List Typical Functions s Hash Functions Collision Resolution

More information

Module 1: Analyzing the Efficiency of Algorithms

Module 1: Analyzing the Efficiency of Algorithms Module 1: Analyzing the Efficiency of Algorithms Dr. Natarajan Meghanathan Professor of Computer Science Jackson State University Jackson, MS 39217 E-mail: natarajan.meghanathan@jsums.edu What is an Algorithm?

More information

Sorting algorithms. Sorting algorithms

Sorting algorithms. Sorting algorithms Properties of sorting algorithms A sorting algorithm is Comparison based If it works by pairwise key comparisons. In place If only a constant number of elements of the input array are ever stored outside

More information

Hashing. Dictionaries Hashing with chaining Hash functions Linear Probing

Hashing. Dictionaries Hashing with chaining Hash functions Linear Probing Hashing Dictionaries Hashing with chaining Hash functions Linear Probing Hashing Dictionaries Hashing with chaining Hash functions Linear Probing Dictionaries Dictionary: Maintain a dynamic set S. Every

More information

Design and Analysis of Algorithms March 12, 2015 Massachusetts Institute of Technology Profs. Erik Demaine, Srini Devadas, and Nancy Lynch Quiz 1

Design and Analysis of Algorithms March 12, 2015 Massachusetts Institute of Technology Profs. Erik Demaine, Srini Devadas, and Nancy Lynch Quiz 1 Design and Analysis of Algorithms March 12, 2015 Massachusetts Institute of Technology 6.046J/18.410J Profs. Erik Demaine, Srini Devadas, and Nancy Lynch Quiz 1 Quiz 1 Do not open this quiz booklet until

More information

Lecture 18 April 26, 2012

Lecture 18 April 26, 2012 6.851: Advanced Data Structures Spring 2012 Prof. Erik Demaine Lecture 18 April 26, 2012 1 Overview In the last lecture we introduced the concept of implicit, succinct, and compact data structures, and

More information

Motivation. Dictionaries. Direct Addressing. CSE 680 Prof. Roger Crawfis

Motivation. Dictionaries. Direct Addressing. CSE 680 Prof. Roger Crawfis Motivation Introduction to Algorithms Hash Tables CSE 680 Prof. Roger Crawfis Arrays provide an indirect way to access a set. Many times we need an association between two sets, or a set of keys and associated

More information

BRICS. Hashing, Randomness and Dictionaries. Basic Research in Computer Science BRICS DS-02-5 R. Pagh: Hashing, Randomness and Dictionaries

BRICS. Hashing, Randomness and Dictionaries. Basic Research in Computer Science BRICS DS-02-5 R. Pagh: Hashing, Randomness and Dictionaries BRICS Basic Research in Computer Science BRICS DS-02-5 R. Pagh: Hashing, Randomness and Dictionaries Hashing, Randomness and Dictionaries Rasmus Pagh BRICS Dissertation Series DS-02-5 ISSN 1396-7002 October

More information

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

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

More information

Lecture 12: Hash Tables [Sp 15]

Lecture 12: Hash Tables [Sp 15] Insanity is repeating the same mistaes and expecting different results. Narcotics Anonymous (1981) Calvin: There! I finished our secret code! Hobbes: Let s see. Calvin: I assigned each letter a totally

More information

CS Data Structures and Algorithm Analysis

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

More information

Lecture 4: Hashing and Streaming Algorithms

Lecture 4: Hashing and Streaming Algorithms CSE 521: Design and Analysis of Algorithms I Winter 2017 Lecture 4: Hashing and Streaming Algorithms Lecturer: Shayan Oveis Gharan 01/18/2017 Scribe: Yuqing Ai Disclaimer: These notes have not been subjected

More information

Data Structures 1 NTIN066

Data Structures 1 NTIN066 Data Structures 1 NTIN066 Jiří Fink https://kam.mff.cuni.cz/ fink/ Department of Theoretical Computer Science and Mathematical Logic Faculty of Mathematics and Physics Charles University in Prague Winter

More information

Optimal Bounds for the Predecessor Problem and Related Problems

Optimal Bounds for the Predecessor Problem and Related Problems Journal of Computer and System Sciences 65, 38 72 (2002) doi:10.1006/jcss.2002.1822 Optimal Bounds for the Predecessor Problem and Related Problems Paul Beame 1 Computer Science and Engineering, University

More information

arxiv:cs/ v1 [cs.ds] 5 Feb 2005

arxiv:cs/ v1 [cs.ds] 5 Feb 2005 On Dynamic Range Reporting in One Dimension Christian Worm Mortensen IT U. Copenhagen cworm@itu.dk Rasmus Pagh IT U. Copenhagen pagh@itu.dk Mihai Pǎtraşcu MIT mip@mit.edu arxiv:cs/0502032v1 [cs.ds] 5 Feb

More information

Data Structures 1 NTIN066

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

More information

Dictionary: an abstract data type

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

More information

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

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

More information

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

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

More information

Lecture 7: More Arithmetic and Fun With Primes

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

More information

Parallelism and Machine Models

Parallelism and Machine Models Parallelism and Machine Models Andrew D Smith University of New Brunswick, Fredericton Faculty of Computer Science Overview Part 1: The Parallel Computation Thesis Part 2: Parallelism of Arithmetic RAMs

More information

A Lecture on Hashing. Aram-Alexandre Pooladian, Alexander Iannantuono March 22, Hashing. Direct Addressing. Operations - Simple

A Lecture on Hashing. Aram-Alexandre Pooladian, Alexander Iannantuono March 22, Hashing. Direct Addressing. Operations - Simple A Lecture on Hashing Aram-Alexandre Pooladian, Alexander Iannantuono March 22, 217 This is the scribing of a lecture given by Luc Devroye on the 17th of March 217 for Honours Algorithms and Data Structures

More information

Trace Reconstruction Revisited

Trace Reconstruction Revisited Trace Reconstruction Revisited Andrew McGregor 1, Eric Price 2, and Sofya Vorotnikova 1 1 University of Massachusetts Amherst {mcgregor,svorotni}@cs.umass.edu 2 IBM Almaden Research Center ecprice@mit.edu

More information

CS 473: Algorithms. Ruta Mehta. Spring University of Illinois, Urbana-Champaign. Ruta (UIUC) CS473 1 Spring / 32

CS 473: Algorithms. Ruta Mehta. Spring University of Illinois, Urbana-Champaign. Ruta (UIUC) CS473 1 Spring / 32 CS 473: Algorithms Ruta Mehta University of Illinois, Urbana-Champaign Spring 2018 Ruta (UIUC) CS473 1 Spring 2018 1 / 32 CS 473: Algorithms, Spring 2018 Universal Hashing Lecture 10 Feb 15, 2018 Most

More information

arxiv: v2 [cs.ds] 8 Apr 2016

arxiv: v2 [cs.ds] 8 Apr 2016 Optimal Dynamic Strings Paweł Gawrychowski 1, Adam Karczmarz 1, Tomasz Kociumaka 1, Jakub Łącki 2, and Piotr Sankowski 1 1 Institute of Informatics, University of Warsaw, Poland [gawry,a.karczmarz,kociumaka,sank]@mimuw.edu.pl

More information

Theoretical Computer Science. Dynamic rank/select structures with applications to run-length encoded texts

Theoretical Computer Science. Dynamic rank/select structures with applications to run-length encoded texts Theoretical Computer Science 410 (2009) 4402 4413 Contents lists available at ScienceDirect Theoretical Computer Science journal homepage: www.elsevier.com/locate/tcs Dynamic rank/select structures with

More information

Computing Techniques for Parallel and Distributed Systems with an Application to Data Compression. Sergio De Agostino Sapienza University di Rome

Computing Techniques for Parallel and Distributed Systems with an Application to Data Compression. Sergio De Agostino Sapienza University di Rome Computing Techniques for Parallel and Distributed Systems with an Application to Data Compression Sergio De Agostino Sapienza University di Rome Parallel Systems A parallel random access machine (PRAM)

More information

Models of Computation

Models of Computation Models of Computation Analysis of Algorithms Week 1, Lecture 2 Prepared by John Reif, Ph.D. Distinguished Professor of Computer Science Duke University Models of Computation (RAM) a) Random Access Machines

More information

A Linear Time Algorithm for Ordered Partition

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

More information

Dominating Set Counting in Graph Classes

Dominating Set Counting in Graph Classes Dominating Set Counting in Graph Classes Shuji Kijima 1, Yoshio Okamoto 2, and Takeaki Uno 3 1 Graduate School of Information Science and Electrical Engineering, Kyushu University, Japan kijima@inf.kyushu-u.ac.jp

More information

25. Minimum Spanning Trees

25. Minimum Spanning Trees 695 25. Minimum Spanning Trees Motivation, Greedy, Algorithm Kruskal, General Rules, ADT Union-Find, Algorithm Jarnik, Prim, Dijkstra, Fibonacci Heaps [Ottman/Widmayer, Kap. 9.6, 6.2, 6.1, Cormen et al,

More information

25. Minimum Spanning Trees

25. Minimum Spanning Trees Problem Given: Undirected, weighted, connected graph G = (V, E, c). 5. Minimum Spanning Trees Motivation, Greedy, Algorithm Kruskal, General Rules, ADT Union-Find, Algorithm Jarnik, Prim, Dijkstra, Fibonacci

More information

Fixed-Universe Successor : Van Emde Boas. Lecture 18

Fixed-Universe Successor : Van Emde Boas. Lecture 18 Fixed-Universe Successor : Van Emde Boas Lecture 18 Fixed-universe successor problem Goal: Maintain a dynamic subset S of size n of the universe U = {0, 1,, u 1} of size u subject to these operations:

More information

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

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

More information

Computing Connected Components Given a graph G = (V; E) compute the connected components of G. Connected-Components(G) 1 for each vertex v 2 V [G] 2 d

Computing Connected Components Given a graph G = (V; E) compute the connected components of G. Connected-Components(G) 1 for each vertex v 2 V [G] 2 d Data Structures for Disjoint Sets Maintain a Dynamic collection of disjoint sets. Each set has a unique representative (an arbitrary member of the set). x. Make-Set(x) - Create a new set with one member

More information

Lecture 5: Fusion Trees (ctd.) Johannes Fischer

Lecture 5: Fusion Trees (ctd.) Johannes Fischer Lecture 5: Fusion Trees (ctd.) Johannes Fischer Fusion Trees fusion tree pred/succ O(lg n / lg w) w.c. construction O(n) w.c. + SORT(n,w) space O(n) w.c. 2 2 Idea B-tree with branching factor b=w /5 b

More information

Priority queues implemented via heaps

Priority queues implemented via heaps Priority queues implemented via heaps Comp Sci 1575 Data s Outline 1 2 3 Outline 1 2 3 Priority queue: most important first Recall: queue is FIFO A normal queue data structure will not implement a priority

More information

6.854 Advanced Algorithms

6.854 Advanced Algorithms 6.854 Advanced Algorithms Homework Solutions Hashing Bashing. Solution:. O(log U ) for the first level and for each of the O(n) second level functions, giving a total of O(n log U ) 2. Suppose we are using

More information

Communication Complexity

Communication Complexity Communication Complexity Jaikumar Radhakrishnan School of Technology and Computer Science Tata Institute of Fundamental Research Mumbai 31 May 2012 J 31 May 2012 1 / 13 Plan 1 Examples, the model, the

More information

Succinct Data Structures for Approximating Convex Functions with Applications

Succinct Data Structures for Approximating Convex Functions with Applications Succinct Data Structures for Approximating Convex Functions with Applications Prosenjit Bose, 1 Luc Devroye and Pat Morin 1 1 School of Computer Science, Carleton University, Ottawa, Canada, K1S 5B6, {jit,morin}@cs.carleton.ca

More information

/463 Algorithms - Fall 2013 Solution to Assignment 4

/463 Algorithms - Fall 2013 Solution to Assignment 4 600.363/463 Algorithms - Fall 2013 Solution to Assignment 4 (30+20 points) I (10 points) This problem brings in an extra constraint on the optimal binary search tree - for every node v, the number of nodes

More information

Bloom Filters, general theory and variants

Bloom Filters, general theory and variants Bloom Filters: general theory and variants G. Caravagna caravagn@cli.di.unipi.it Information Retrieval Wherever a list or set is used, and space is a consideration, a Bloom Filter should be considered.

More information

Limits of Feasibility. Example. Complexity Relationships among Models. 1. Complexity Relationships among Models

Limits of Feasibility. Example. Complexity Relationships among Models. 1. Complexity Relationships among Models Limits of Feasibility Wolfgang Schreiner Wolfgang.Schreiner@risc.jku.at Research Institute for Symbolic Computation (RISC) Johannes Kepler University, Linz, Austria http://www.risc.jku.at 1. Complexity

More information

BRICS. Faster Deterministic Dictionaries. Basic Research in Computer Science BRICS RS R. Pagh: Faster Deterministic Dictionaries.

BRICS. Faster Deterministic Dictionaries. Basic Research in Computer Science BRICS RS R. Pagh: Faster Deterministic Dictionaries. BRICS Basic Research in Computer Science BRICS RS-99-48 R. Pagh: Faster Deterministic Dictionaries Faster Deterministic Dictionaries Rasmus Pagh BRICS Report Series RS-99-48 ISSN 0909-0878 December 1999

More information

Lecture 24: Approximate Counting

Lecture 24: Approximate Counting CS 710: Complexity Theory 12/1/2011 Lecture 24: Approximate Counting Instructor: Dieter van Melkebeek Scribe: David Guild and Gautam Prakriya Last time we introduced counting problems and defined the class

More information

2 RASMUS PAGH bulky data. This means that the best space complexity one can hope for is O(n) words, where n is the size of S. We will only consider da

2 RASMUS PAGH bulky data. This means that the best space complexity one can hope for is O(n) words, where n is the size of S. We will only consider da Nordic Journal of Computing A TRADE-OFF FOR WORST-CASE EFFICIENT DICTIONARIES RASMUS PAGH Λ BRICS y, Department of Computer Science, University of Aarhus, DK 8000 νarhus C, Denmark pagh@brics.dk Abstract.

More information

Sliding Windows with Limited Storage

Sliding Windows with Limited Storage Electronic Colloquium on Computational Complexity, Report No. 178 (2012) Sliding Windows with Limited Storage Paul Beame Computer Science and Engineering University of Washington Seattle, WA 98195-2350

More information

A Tight Lower Bound for Dynamic Membership in the External Memory Model

A Tight Lower Bound for Dynamic Membership in the External Memory Model A Tight Lower Bound for Dynamic Membership in the External Memory Model Elad Verbin ITCS, Tsinghua University Qin Zhang Hong Kong University of Science & Technology April 2010 1-1 The computational model

More information

Hashing. Martin Babka. January 12, 2011

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

More information

arxiv: v1 [cs.cc] 14 Sep 2013

arxiv: v1 [cs.cc] 14 Sep 2013 arxiv:1309.3690v1 [cs.cc] 14 Sep 2013 Element Distinctness, Frequency Moments, and Sliding Windows Paul Beame Computer Science and Engineering University of Washington Seattle, WA 98195-2350 beame@cs.washington.edu

More information

CSCB63 Winter Week10 - Lecture 2 - Hashing. Anna Bretscher. March 21, / 30

CSCB63 Winter Week10 - Lecture 2 - Hashing. Anna Bretscher. March 21, / 30 CSCB63 Winter 2019 Week10 - Lecture 2 - Hashing Anna Bretscher March 21, 2019 1 / 30 Today Hashing Open Addressing Hash functions Universal Hashing 2 / 30 Open Addressing Open Addressing. Each entry in

More information

Trace Reconstruction Revisited

Trace Reconstruction Revisited Trace Reconstruction Revisited Andrew McGregor 1, Eric Price 2, Sofya Vorotnikova 1 1 University of Massachusetts Amherst 2 IBM Almaden Research Center Problem Description Take original string x of length

More information

CS6999 Probabilistic Methods in Integer Programming Randomized Rounding Andrew D. Smith April 2003

CS6999 Probabilistic Methods in Integer Programming Randomized Rounding Andrew D. Smith April 2003 CS6999 Probabilistic Methods in Integer Programming Randomized Rounding April 2003 Overview 2 Background Randomized Rounding Handling Feasibility Derandomization Advanced Techniques Integer Programming

More information

Quiz 1 Solutions. Problem 2. Asymptotics & Recurrences [20 points] (3 parts)

Quiz 1 Solutions. Problem 2. Asymptotics & Recurrences [20 points] (3 parts) Introduction to Algorithms October 13, 2010 Massachusetts Institute of Technology 6.006 Fall 2010 Professors Konstantinos Daskalakis and Patrick Jaillet Quiz 1 Solutions Quiz 1 Solutions Problem 1. We

More information

CS361 Homework #3 Solutions

CS361 Homework #3 Solutions CS6 Homework # Solutions. Suppose I have a hash table with 5 locations. I would like to know how many items I can store in it before it becomes fairly likely that I have a collision, i.e., that two items

More information