Chapter 14: Augmenting Data Structures

Slides:



Advertisements
Similar presentations
Introduction to Algorithms
Advertisements

CSE 4101/5101 Prof. Andy Mirzaian Augmenting Data Structures.
Comp 122, Spring 2004 Binary Search Trees. btrees - 2 Comp 122, Spring 2004 Binary Trees  Recursive definition 1.An empty tree is a binary tree 2.A node.
Augmenting Data Structures Advanced Algorithms & Data Structures Lecture Theme 07 – Part I Prof. Dr. Th. Ottmann Summer Semester 2006.
Jan Binary Search Trees What is a search binary tree? Inorder search of a binary search tree Find Min & Max Predecessor and successor BST insertion.
Binary Search Trees Many of the slides are from Prof. Plaisted’s resources at University of North Carolina at Chapel Hill.
ALGORITHMS THIRD YEAR BANHA UNIVERSITY FACULTY OF COMPUTERS AND INFORMATIC Lecture six Dr. Hamdy M. Mousa.
Binary Search Trees. A binary search tree is a binary tree that keeps the following property: Every element is larger than all elements in its left sub-tree.
Binary Search Trees Comp 550.
CS 473Lecture X1 CS473-Algorithms I Lecture X Augmenting Data Structures.
David Luebke 1 5/22/2015 CS 332: Algorithms Augmenting Data Structures: Interval Trees.
Augnenting data structures Augment an existing data structure to apply to a new problem. Red-black tree as an example.
14. Augmenting Data Structures Hsu, Lih-Hsing. Computer Theory Lab. Chapter 13P Dynamic order statistics We shall also see the rank of an element―its.
CSE 2331/5331 Topic 10: Balanced search trees Rotate operation Red-black tree Augmenting data struct.
Analysis of Algorithms CS 477/677 Instructor: Monica Nicolescu Lecture 10.
2IL50 Data Structures Spring 2015 Lecture 8: Augmenting Data Structures.
Analysis of Algorithms CS 477/677 Instructor: Monica Nicolescu Lecture 12.
Tirgul 5 AVL trees.
10/22/2002CSE Red Black Trees CSE Algorithms Red-Black Trees Augmenting Search Trees Interval Trees.
Tirgul 5 Comparators AVL trees. Comparators You already know interface Comparable which is used to compare objects. By implementing the interface, one.
Augmenting Data Structures Advanced Algorithms & Data Structures Lecture Theme 07 – Part II Prof. Dr. Th. Ottmann Summer Semester 2006.
Data Structures, Spring 2006 © L. Joskowicz 1 Data Structures – LECTURE Binary search trees Motivation Operations on binary search trees: –Search –Minimum,
Tirgul 5 This tirgul is about AVL trees. You will implement this in prog-ex2, so pay attention... BTW - prog-ex2 is on the web. Start working on it!
DAST 2005 Tirgul 7 Binary Search Trees. DAST 2005 Motivation We would like to have a dynamic ADT that efficiently supports the following common operations:
Introduction to Analysis of Algorithms CAS CS 330 Lecture 16 Shang-Hua Teng Thanks to Charles E. Leiserson and Silvio Micali of MIT for these slides.
Interval Trees.
David Luebke 1 9/18/2015 CS 332: Algorithms Red-Black Trees.
Lecture X Augmenting Data Structures
Interval Trees CS302 Data Structures Modified from Dr Monica Nicolescu.
Analysis of Red-Black Tree Because of the rules of the Red-Black tree, its height is at most 2log(N + 1). Meaning that it is a balanced tree Time Analysis:
2IL50 Data Structures Fall 2015 Lecture 9: Range Searching.
CS 361 – Chapter 3 Sorted dictionary ADT Implementation –Sorted array –Binary search tree.
Introduction to Algorithms 6.046J/18.401J/SMA5503 Lecture 11 Prof. Erik Demaine.
Red-Black Trees. Review: Binary Search Trees ● Binary Search Trees (BSTs) are an important data structure for dynamic sets ● In addition to satellite.
2IL05 Data Structures Spring 2010 Lecture 9: Augmenting Data Structures.
COSC 2007 Data Structures II Chapter 13 Advanced Implementation of Tables II.
Analysis of Algorithms CS 477/677 Instructor: Monica Nicolescu Lecture 10.
Binary Search Trees What is a binary search tree?
Lecture 23 Red Black Tree Chapter 10 of textbook
Analysis of Algorithms CS 477/677
AA Trees.
Balanced Search Trees Modified from authors’ slides.
Lec 13 Oct 17, 2011 AVL tree – height-balanced tree Other options:
Introduction to Algorithms
BCA-II Data Structure Using C
Data Structures – LECTURE Balanced trees
Binary search tree. Removing a node
Dynamic Order Statistics
AVL Tree Mohammad Asad Abbasi Lecture 12
AVL Tree.
Summary of General Binary search tree
Lecture 25 Splay Tree Chapter 10 of textbook
Ch. 12: Binary Search Trees Ming-Te Chi
Augmenting Data Structures
Red-Black Trees v z Red-Black Trees 1 Red-Black Trees
Ch. 12: Binary Search Trees Ming-Te Chi
Binary Search Trees (13.1/12.1)
CS 583 Analysis of Algorithms
Introduction to Algorithms
AVL-Trees.
CSE2331/5331 Topic 7: Balanced search trees Rotate operation
Chapter 20: Binary Trees.
Lecture 10 Oct 1, 2012 Complete BST deletion Height-balanced BST
Design and Analysis of Algorithms
Augmenting Data Structures: Interval Trees
Analysis of Algorithms CS 477/677
Binary Search Trees Comp 122, Spring 2004.
Chapter 12&13: Binary Search Trees (BSTs)
Interval Trees CS302 Data Structures Modified from Dr Monica Nicolescu.
Chapter 11 Trees © 2011 Pearson Addison-Wesley. All rights reserved.
Presentation transcript:

Chapter 14: Augmenting Data Structures

Dynamic order statistics QUERY: OS(x,i) – the node containing the i-th smallest element in the subtree rooted at x How to augment so that the following can be done efficiently: The query itself Maintaining augmented data (under Insert, Delete)

Added field to red-black trees: size(x): # nodes in the subtree rooted at x Process the query Determine the rank of an element x Count size[left[x]]+1. When climbing left (since right child of parent) increment count by size[left[parent[x]]]+1

Maintaining subtree sizes Since the main tool for insert/delete  Theorem: Query, Insert, Delete still take O(log n) time each

Interval trichotomy for 2 closed intervals i and i’ i and i’ can overlap in 4 ways or to not overlap in 2 ways: Each way is represented by conditions on (some subset of) low(i),high(i),low(i’),high(i’)

Interval trees Red Black tree by left(i) of intervals INTERVAL-SEARCH(T,i) – find a node in T whose interval overlaps interval i or report: none exists Start with root. If i does not overlap current node x of T, then if max[left[x]]>=low(i) proceed to left[x]; else proceed to right[x]

Theorem: INTERVAL-SEARCH is correct Proof: Case (a). INTERVAL-SEARCH goes right. No interval on left subtree can overlap I. Case (b). INTERVAL-SEARCH goes left. If no interval in left the subtree overlaps i, also no interval of of the right subtree could overlap i.