Paolo Ferragina Dipartimento di Informatica, Università di Pisa

Slides:



Advertisements
Similar presentations
Space-Efficient Static Trees and Graphs Guy Jacobson IEEE Symposium on Foundations of Computer Science, 1989 Speaker: 吳展碩.
Advertisements

Interval Heaps Complete binary tree. Each node (except possibly last one) has 2 elements. Last node has 1 or 2 elements. Let a and b be the elements in.
Trees1 More on Trees University Fac. of Sci. & Eng. Bus. School Law School CS Dept. EE Dept. Math. Dept.
Succinct Representation of Balanced Parentheses, Static Trees and Planar Graphs J. Ian Munro & Venkatesh Raman.
An Improved Succinct Dynamic k-Ary Tree Representation (work in progress) Diego Arroyuelo Department of Computer Science, Universidad de Chile.
Paolo Ferragina, Università di Pisa Compressed Rank & Select on general strings Paolo Ferragina Dipartimento di Informatica, Università di Pisa.
Succinct Representations of Trees S. Srinivasa Rao Seoul National University.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2009 Heap Lecture Chapter 6 Use NOTES feature to see explanation.
1 Pertemuan 20 Binomial Heap Matakuliah: T0026/Struktur Data Tahun: 2005 Versi: 1/1.
Trees and Red-Black Trees Gordon College Prof. Brinton.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Spring, 2007 Heap Lecture Chapter 6 Use NOTES feature to see explanation.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2001 Heap Lecture 2 Chapter 7 Wed. 10/10/01 Use NOTES feature to.
Balanced Trees Balanced trees have height O(lg n).
Mike 66 Sept Succinct Data Structures: Techniques and Lower Bounds Ian Munro University of Waterloo Joint work with/ work of Arash Farzan, Alex Golynski,
Basics of Data Compression Paolo Ferragina Dipartimento di Informatica Università di Pisa.
Succinct Representations of Trees
Introduction n – length of text, m – length of search pattern string Generally suffix tree construction takes O(n) time, O(n) space and searching takes.
Summer School '131 Succinct Data Structures Ian Munro.
Binary Trees 2 Overview Trees. Terminology. Traversal of Binary Trees. Expression Trees. Binary Search Trees.
1 Red-Black Trees By Mary Hudachek-Buswell Red Black Tree Properties Rotate Red Black Trees Insertion Red Black Trees.
Tree Data Structures.
Succinct Data Structures Ian Munro University of Waterloo Joint work with David Benoit, Andrej Brodnik, D, Clark, F. Fich, M. He, J. Horton, A. López-Ortiz,
Random access to arrays of variable-length items
Trees CS 105. L9: Trees Slide 2 Definition The Tree Data Structure stores objects (nodes) hierarchically nodes have parent-child relationships operations.
2-3 Trees Extended tree.  Tree in which all empty subtrees are replaced by new nodes that are called external nodes.  Original nodes are called internal.
Data Structure II So Pak Yeung Outline Review  Array  Sorted Array  Linked List Binary Search Tree Heap Hash Table.
Binary Heaps Text Read Weiss, § Binary Heap One-array representation of a tree Complete trees Building a Binary Heap Insert Delete.
Binary Tree 10/22/081. Tree A nonlinear data structure Contain a distinguished node R, called the root of tree and a set of subtrees. Two nodes n1 and.
1 Fat heaps (K & Tarjan 96). 2 Goal Want to achieve the performance of Fibonnaci heaps but on the worst case. Why ? Theoretical curiosity and some applications.
Index construction: Compression of postings Paolo Ferragina Dipartimento di Informatica Università di Pisa Reading 5.3 and a paper.
Red-Black Tree Insertion Start with binary search insertion, coloring the new node red NIL l Insert 18 NIL l NIL l 1315 NIL l
BINARY TREES A BINARY TREE t IS EITHER EMPTY OR CONSISTS OF AN ITEM, CALLED THE ROOT ITEM, AND TWO DISTINCT BINARY TREES, CALLED THE LEFT SUBTREE AND.
1Computer Sciences. 2 HEAP SORT TUTORIAL 4 Objective O(n lg n) worst case like merge sort. Sorts in place like insertion sort. A heap can be stored as.
Question 4 Tutorial 8. Part A Insert 20, 10, 15, 5,7, 30, 25, 18, 37, 12 and 40 in sequence into an empty binary tree
Fibonacci Heap Fibonacci heapshave better asymptotic time bounds than binary heaps for the INSERT, UNION, and DECREASE-KEY operations, and they.
Nov 2, 2001CSE 373, Autumn Hash Table example marking deleted items + choice of table size.
Index construction: Compression of postings
Analysis of Algorithms
Andreas Klappenecker [partially based on the slides of Prof. Welch]
IS 320 (Modified slightly for instruction in INFO 320 at UW).
Data Structures Binomial Heaps Fibonacci Heaps Haim Kaplan & Uri Zwick
Binary search tree. Removing a node
AVL Tree.
Section 8.1 Trees.
CS Anya E. Vostinar Grinnell College
Insert in amortized cost O(1), Merge in O(lgn) DeleteMax in O(lgn)
Slide Sources: CLRS “Intro. To Algorithms” book website
Lecture 25 Splay Tree Chapter 10 of textbook
Data Structures Lecture 27 Sohail Aslam.
TREES General trees Binary trees Binary search trees AVL trees
Binary Heaps Text Binary Heap Building a Binary Heap
Slide Sources: CLRS “Intro. To Algorithms” book website
Tree A tree is a data structure in which each node is comprised of some data as well as node pointers to child nodes
Lecture 29 Heaps Chapter 12 of textbook Concept of heaps Binary heaps
Trees & Forests D. J. Foreman.
Index construction: Compression of postings
Forests D. J. Foreman.
CS223 Advanced Data Structures and Algorithms
Trees (Part 1, Theoretical)
Paolo Ferragina Dipartimento di Informatica, Università di Pisa
Lecture 36 Section 12.2 Mon, Apr 23, 2007
Trees Addenda.
Representing binary trees with lists
Index construction: Compression of postings
Index construction: Compression of postings
Paolo Ferragina Dipartimento di Informatica, Università di Pisa
Chapter 20: Binary Trees.
Succinct Data Structures
Tree and its terminologies
Lecture 21 Amortized Analysis
Presentation transcript:

Paolo Ferragina Dipartimento di Informatica, Università di Pisa Representing Trees Paolo Ferragina Dipartimento di Informatica, Università di Pisa Paolo Ferragina, Università di Pisa

Standard representation Binary tree: each node has two pointers to its left and right children An n-node tree takes 2n pointers or 2n lg n bits. Supports finding left child or right child of a node (in constant time). For each extra operation (eg. parent, subtree size) we have to pay additional n lg n bits each. x x x x x x x x x

Can we improve the space bound? There are less than 22n distinct binary trees on n nodes. 2n bits are enough to distinguish between any two different binary trees. Can we represent an n node binary tree using 2n bits?

Binary tree representation A binary tree on n nodes can be represented using 2n+o(n) bits to support: parent left child right child in constant time.

Heap-like notation for a binary tree 1 Add external nodes 1 1 Label internal nodes with a 1 and external nodes with a 0 1 1 1 1 1 Write the labels in level order 1 1 1 1 0 1 1 0 1 0 0 1 0 0 0 0 0 One can reconstruct the tree from this sequence An n node binary tree can be represented in 2n+1 bits. What about the operations?

Heap-like notation for a binary tree 1 x  x: # 1’s up to x (Rank) x  x: position of x-th 1 (Select) 1 2 3 2 3 4 5 6 7 left child(x) = On green(2x) 4 5 6 12 8 9 10 11 13 right child(x) = On green(2x+1) 7 8 parent(x) = On red (⌊x/2⌋) 14 15 16 17 1 2 3 4 5 6 7 8 1 1 1 1 0 1 1 0 1 0 0 1 0 0 0 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17