Presentation is loading. Please wait.

Presentation is loading. Please wait.

Succinct Data Structures

Similar presentations


Presentation on theme: "Succinct Data Structures"— Presentation transcript:

1 Succinct Data Structures
Kunihiko Sadakane National Institute of Informatics

2 Succinct Data Structures for Trees
Consider only ordered trees Ordered/Unordered trees Child nodes are ordered/not ordered Concerning unordered trees, trees can be regarded as the same if they become the same shape by reordering children Edges are labeled/not labeled Node labels can be represented by edge labels on the edge toward parent nodes

3 Ordered Trees ordered tree / ordinal tree Rooted trees
Children of each node are ordered No labels With edge labels → cardinal tree 2 6 8 1 7 3 5 4

4 Succinct Representations of Ordered Trees
LOUDS (level order unary degree sequence) BP (balanced parentheses) DFUDS (depth first unary degree sequence)

5 LOUDS Representation [1,2]
Degrees of nodes are encoded by unary codes in breadth-first order degree d → 1d0 2n+1 bits for n nodes (matches the lower bound) i-th node is represented by i-th 1 2 3 8 1 7 4 6 5 L 1 2 3 4 5 6 7 8 LOUDS

6 Tree Navigational Operations (1)
i-th node: select1(L, i) (i  1) firstchild(x) y := select0(rank1(L,x))+1 if L[y] = 0 then 1 else y lastchild(x) y := select0(rank1(L,x)+1)1 2 3 8 1 7 4 6 5 1 2 3 4 5 6 7 8 LOUDS L

7 Tree Navigational Operations (2)
sibling(x) if L[x+1] = 0 then 1 else x+1 parent(x) = select1(rank0(L,x)) degree(x) = lastchild(x)  firstchild(x) + 1 Merits: supported by only rank/select Demerits: cannot compute subtree sizes 2 3 8 1 7 4 6 5 1 2 3 4 5 6 7 8 LOUDS L

8 BP Representation [3] ((()()())(()()))
Each node is represented by a pair of matching open and close parentheses 2n bits for n nodes The size matches the lower bound 2 6 8 1 7 3 5 4 P ((()()())(()())) BP

9 Basic Operations on BP A node is represented by the position of (
findclose(P,i): returns the position of )matching with( at P[i] enclose(P,i): returns the position of ( which encloses ( at P[i] enclose findclose 1 1 2 3 4 5 6 7 8 9 10 11 2 3 11 8 P (()((()())())(()())()) 4 7 9 10 5 6

10 Tree Navigational Operations
parent(v) = enclose(P,v) firstchild(v) = v + 1 sibling(v) = findclose(P,v) + 1 lastchild(v) = findopen(P, findclose(P,v)1) 1 enclose findclose 2 3 8 11 1 2 3 4 5 6 7 8 9 10 11 4 (()((()())())(()())()) 7 9 10 5 6

11 Number of Descendants (Subtree Size)
The size of the subtree rooted at v is subtreesize(v) = (findclose(P,v)v+1)/2 degree (#children) can be computed by repeatedly applying findclose, but it takes time proportional to the number of children 1 2 3 11 1 2 3 4 5 6 7 8 9 10 11 8 P (()((()())())(()())()) 4 7 9 10 5 6

12 Data Structure for findclose [4]
Divide the parentheses sequence into blocks of length B = ½ log n b(p): block number containing p (p): position of parenthesis matching p parenthesis p is said to be far ⇔ b(p)  b((p)) Far open parenthesis p is said to be opening pioneer ⇔ For the far open parenthesis q which is immediately precedes p, b((p))  b((q)) Represent positions of parentheses which match with opening pioneers are represented by 0,1 vector ( ( ) ) ) p (p) (q) q r ( (r)

13 Lemma: Let  denote the number of blocks
Lemma: Let  denote the number of blocks. Then the number of opening pioneers is at most 23. Proof: A graph whose nodes correspond to the blocks and whose edges are (b(p), b((p)) is an outer-planar graph. Opening/closing pioneers form a BP again.  = n/B = 2n/log n ⇒ Length of BP is O(n/log n)

14 Representing Recursive Structure
opening pioneers and their matching parentheses are represented by a 0,1 vector B B is a sparse vector of length 2n with O(n/log n) 1’s Can be represented in O(n log log n/log n) bits ( ( ) ) ) p (p) (q) q r ( (r) P B 0100 0101 0000 0000 0010 1001 P1 ((()))

15 Let S(n) denote the size of BP representation for an n node tree
S(n) = 2n + O(n log log n/log n) + S(O(n/log n)) If the number of nodes becomes O(n/log2 n), a naïve data structure which stores all the answers uses only O(n/log n) bits Therefore S(n) = 2n + O(n log log n/log n)

16 Algorithm for findclose
To compute (p) = findclose(P,p) If p is not far, (p) is computed by a table Find the pioneer p* that immediately precedes p Find (p*) using the BP for pioneers If p is not pioneer, b((p))  b((p*)) The position of (p) is determined from the difference between depths of p and p* p* p (p) (p*) ( ( ) )

17 References [1] G. Jacobson. Space-efficient Static Trees and Graphs. In Proc. IEEE FOCS, pages 549–554, 1989. [2] O'Neil Delpratt, Naila Rahman, Rajeev Raman: Engineering the LOUDS Succinct Tree Representation. WEA 2006: [3] J. I. Munro and V. Raman. Succinct Representation of Balanced Parentheses and Static Trees. SIAM Journal on Computing, 31(3):762–776, 2001. [4] R. F. Geary, N. Rahman, R. Raman, and V. Raman. A simple optimal representation for balanced parentheses. Theoretical Computer Science, 368:231–246, December 2006. [5] J. Ian Munro, Venkatesh Raman, and S. Srinivasa Rao. Space efficient suffix trees. Journal of Algorithms, 39:205–222, 2001. [6] D. Benoit, E. D. Demaine, J. I. Munro, R. Raman, V. Raman, and S. S. Rao. Representing Trees of Higher Degree. Algorithmica, 43(4):275–292, 2005.

18 [7] J. Jansson, K. Sadakane, and W. -K. Sung
[7] J. Jansson, K. Sadakane, and W.-K. Sung. Ultra-succinct Representation of Ordered Trees. In Proc. ACM-SIAM SODA, pages 575–584, 2007. [8] A. Farzan and J. I. Munro. A Uniform Approach Towards Succinct Representation of Trees. In Proc. SWAT, LNCS 5124, pages 173–184, 2008. [9] A. Farzan, R. Raman, and S. S. Rao. Universal Succinct Representations of Trees? In Proc. ICALP, LNCS 5555, pages 451–462, 2009. [10] P. Ferragina, F. Luccio, G. Manzini, and S. Muthukrishnan. Compressing and indexing labeled trees, with applications. Journal of the ACM, 57(1):4:1–4:33, 2009. [11] R. F. Geary, R. Raman, and V. Raman. Succinct ordinal trees with levelancestor queries. ACM Trans. Algorithms, 2:510–534, 2006. [12] H.-I. Lu and C.-C. Yeh. Balanced parentheses strike back. ACM Transactions on Algorithms (TALG), 4(3):No. 28, 2008.


Download ppt "Succinct Data Structures"

Similar presentations


Ads by Google