Priority Search Trees Keys are pairs (x,y).

Slides:



Advertisements
Similar presentations
Splay Trees Binary search trees.
Advertisements

6/14/2015 6:48 AM(2,4) Trees /14/2015 6:48 AM(2,4) Trees2 Outline and Reading Multi-way search tree (§3.3.1) Definition Search (2,4)
Binary Search Trees1 ADT for Map: Map stores elements (entries) so that they can be located quickly using keys. Each element (entry) is a key-value pair.
© 2004 Goodrich, Tamassia (2,4) Trees
10/20/2015 2:03 PMRed-Black Trees v z. 10/20/2015 2:03 PMRed-Black Trees2 Outline and Reading From (2,4) trees to red-black trees (§9.5) Red-black.
B + -Trees Same structure as B-trees. Dictionary pairs are in leaves only. Leaves form a doubly-linked list. Remaining nodes have following structure:
1 Data Structures and Algorithms Searching Red-Black and Other Dynamically BalancedTrees.
Data Structures and Algorithms TREE-TRAVERSAL. Searching - Re-visited Binary tree O(log n) if it stays balanced Simple binary tree good for static collections.
Binary Search Trees   . 2 Binary Search Tree Properties A binary search tree is a binary tree storing keys (or key-element pairs) at its.
Fall 2006 CSC311: Data Structures 1 Chapter 10: Search Trees Objectives: Binary Search Trees: Search, update, and implementation AVL Trees: Properties.
Segment Trees Basic data structure in computational geometry. Computational geometry.  Computations with geometric objects.  Points in 1-, 2-, 3-, d-space.
AVL trees1 AVL Trees Height of a node : The height of a leaf is 1. The height of a null pointer is zero. The height of an internal node is the maximum.
Priority Search Trees Keys are pairs (x,y). Basic (search, insert, delete) and rectangle operations. Two varieties.  Based on a balanced binary search.
Tree Representation and Terminology Binary Trees Binary Search Trees Pointer-Based Representation of a Binary Tree Array-Based Representation of a Binary.
Leftist Trees Linked binary tree.
Part-D1 Binary Search Trees
AA Trees.
File Organization and Processing Week 3
BCA-II Data Structure Using C
Red-Black Trees v z Red-Black Trees Red-Black Trees
Red-Black Trees 5/17/2018 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and.
Red-Black Trees 5/22/2018 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and.
Search Trees.
Interval Trees Store intervals of the form [li,ri], li <= ri.
Binary search tree. Removing a node
Lecture 15 AVL Trees Slides modified from © 2010 Goodrich, Tamassia & by Prof. Naveen Garg’s Lectures.
Red Black Trees
Splay Trees Binary search trees.
Multidimensional Range Search
Multiway search trees and the (2,4)-tree
AVL DEFINITION An AVL tree is a binary search tree in which the balance factor of every node, which is defined as the difference between the heights of.
AVL Tree.
Red-Black Trees v z Red-Black Trees 1 Red-Black Trees
Chapter 10.1 Binary Search Trees
Red-Black Trees 9/12/ :44 AM AVL Trees v z AVL Trees.
Summary of General Binary search tree
Dynamic Dictionaries Primary Operations: Additional operations:
Splay Trees Binary search trees.
CMPS 3130/6130 Computational Geometry Spring 2017
Interval Heaps Complete binary tree.
Red-Black Trees 11/13/2018 2:07 AM AVL Trees v z AVL Trees.
(2,4) Trees (2,4) Trees 1 (2,4) Trees (2,4) Trees
Chapter 6 Transform and Conquer.
Wednesday, April 18, 2018 Announcements… For Today…
B-Trees (continued) Analysis of worst-case and average number of disk accesses for an insert. Delete and analysis. Structure for B-tree node.
Red-Black Trees v z Red-Black Trees 1 Red-Black Trees
Binary Search Trees < > =
Red-Black Trees v z /20/2018 7:59 AM Red-Black Trees
Red-Black Trees v z Red-Black Trees Red-Black Trees
Red-Black Trees 11/26/2018 3:42 PM AVL Trees v z AVL Trees.
Red-Black Trees 2018年11月26日3时46分 AVL Trees v z AVL Trees.
(2,4) Trees /26/2018 3:48 PM (2,4) Trees (2,4) Trees
Segment Trees Basic data structure in computational geometry.
Priority Search Trees Modified Prof. Sahni’s notes.
Data Structures and Algorithms
(2,4) Trees (2,4) Trees (2,4) Trees.
Red-Black Trees v z /17/2019 4:20 PM Red-Black Trees
(2,4) Trees 2/15/2019 (2,4) Trees (2,4) Trees.
Lecture 36 Section 12.2 Mon, Apr 23, 2007
(2,4) Trees /24/2019 7:30 PM (2,4) Trees (2,4) Trees
Red-Black Trees 2/24/ :17 AM AVL Trees v z AVL Trees.
(2,4) Trees (2,4) Trees (2,4) Trees.
AVL-Trees.
(2,4) Trees /6/ :26 AM (2,4) Trees (2,4) Trees
Red-Black Trees 5/19/2019 6:39 AM AVL Trees v z AVL Trees.
Red Black Trees.
Binary Search Trees < > = Dictionaries
Red-Black Trees v z /6/ :10 PM Red-Black Trees
Dictionaries 二○一九年九月二十四日 ADT for Map:
CS210- Lecture 20 July 19, 2005 Agenda Multiway Search Trees 2-4 Trees
Presentation transcript:

Priority Search Trees Keys are pairs (x,y). Basic (search, insert, delete) and rectangle operations. Two varieties. Based on a balanced binary search tree such as a red-black tree. Red-black Priority Search Tree (RBPST) Based on a radix search tree. Radix Priority Search Tree (RPST)

Radix Priority Search Tree All x values are different, integral, and in the range [0, k – 1]. Each node of the priority search tree has exactly one element. Min tree on y. Radix tree on x. When x values are not different we may transform (x,y) to (xM+y,y), when y values are integral and in the range [0,M-1]. For rectangle ops, left boundary becomes x_L * M and right becomes x_R * M + M-1. This preserves the integrity of rectangle operations.

Radix Priority Search Tree The y value of the element in node w is <= the y value of all elements in the subtree rooted at w (y values define a min tree). Root interval is [0,k). Interval for node w is [a,b). Left child interval is [a, floor((a+b)/2)). Right child interval is [floor((a+b)/2, b)). Similar to point segment tree (each leaf is a point rather than a unit interval).

Insert Start with empty RPST. k = 16. Root interval is [0,16). 5,8 [0,16) Insert (6,9). (5,8) remains in root, because 8 < 9. (6,9) inserted in left subtree, because 6 is in the left child interval. 5,8 6,9 [0,16) [0,8) Note that despite the fact that 6 > 5, 6 is in the left subtree. Radix search tree; not binary search tree.

Insert Insert (7,1). (7,1) goes into the root, because 1 < 8. 5,8 6,9 [0,16) [0,8) Insert (7,1). (7,1) goes into the root, because 1 < 8. (5,8) inserted in left subtree, because 5 is in the left child interval. (5,8) displaces (6,9), because 8 < 9. 7,1 [0,16) 5,8 [0,8) (6,9) inserted in right subtree, because 6 is in the right child interval. 6,9 [4,8)

Insert Insert (11,5). 7,1 [0,16) 5,8 [0,8) 6,9 [4,8) 7,1 [0,16) 5,8 [8,16) 11,5 Insert (11,5).

Properties Height is O(log k). Insert time is O(log k). 7,1 [0,16) 5,8 [0,8) 6,9 [4,8) [8,16) 11,5 2,12 [0,4) Height is O(log k). Insert time is O(log k).

Search Search time is O(log k). 7,1 [0,16) 5,8 [0,8) 6,9 [4,8) [8,16) 11,5 2,12 [0,4) If root y > y of search key, quit. Search time is O(log k).

Delete Similar to delete min of min heap. Delete time is O(log k). 7,1 [0,16) 5,8 [0,8) 6,9 [4,8) [8,16) 11,5 2,12 [0,4) Similar to delete min of min heap. Delete time is O(log k).

minXinRectangle(xL,xR,yT) 12,1 [0,16) 5,8 [0,8) 6,9 [4,8) [8,16) 11,5 2,12 [0,4) [12,16) 14,6 If root y-value is > yT quit. Check if root is a candidate (I.e., is it in the rectangle). Search for a better candidate in the left subtree if x-range of left subtree overlaps with x-range of rectangle. Search right subtree only if left subtree does not have a point in the rectangle (provided, of course, there is an x-range overlap). Discontinue descent if you reach a node with a point above the rectangle. minXinRectangle(6,12,7). Time is O(log k).

Complexity yok ynotOK Profile of visited nodes. We shall say that a node is visited/examined iff a comparison is made to determine whether its y value is > yT. Only nodes that have an x-range overlap with query rectangle may be examined. Label all examined nodes as yok or ynotOK depending on whether the y-value of the element in that node is <= yT. Only nodes labeled yok may have examined children. Profile of visited nodes.

Complexity yok ynotOK Yellow node is node closest to root with 2 examined children.

Complexity yok ynotOK No yellow node  O(log k) examined nodes If there is no such node, then only O(log k) nodes are examined. If there is a yellow node its y must be OK as it has examined children. The yellow node is unique, because if two nodes on the same level satisfy the property then their nearest common ancestor also satisfies the property and is closer to the root. Note that only nodes whose y-value is within the y-range may have an examined child. That is, the parent (if any) of an examined node must be labeled yok. Equivalently, every ancestor of an OK node is also OK. No yellow node  O(log k) examined nodes Yellow node  unique

Complexity yok ynotOK Assume both children of the yellow node are yok. The other cases are similar.

Complexity yok ynotOK If blue circled node has an OK y-value, it represents a point in the rectangle, because its left sibling has an x-range overlap with the rectangle as does the right child of the yellow node (so the x-range of the blue circled node is contained in the rectangle). So, the right subtree of the yellow circled node cannot be entered and the right child of the yellow node is not examined. Therefore, this blue circled node cannot have an OK y-value and so the subtree of which it is root is not entered. Similarly, if the red circled node has an OK y-value, its element is in the given rectangle and its right sibling is not examined. So, there can be at most one node that has two children labeled yok. No other node in the yellow node’s subtree can have two children marked yok.

Complexity yok ynotOK # nodes visited < 4log k. No node in the yellow node’s subtree can have two children marked yok. If blue circled node has an OK y-value, it represents a point in the rectangle. So, the right subtree of the yellow circled node cannot be entered and the right child of the yellow node is not examined. Therefore, this blue circled node cannot have an OK y-value and so the subtree of which it is root is not entered. Similarly, if the red circled node has an OK y-value, its element is in the given rectangle and its right sibling is not examined. So, there can be at most one node that has two children labeled yok. # nodes visited < 4log k.

maxXinRectangle(xL,xR,yT) 12,1 [0,16) 5,8 [0,8) 6,9 [4,8) [8,16) 11,5 2,12 [0,4) [12,16) 14,6 If root y-value is > yT quit. Check if root is a candidate (I.e., is it in the rectangle). Search for a better candidate in the right subtree. Search left subtree only if right subtree does not have a point in the rectangle. Discontinue descent if you reach a node with a point above the rectangle. As before, a subtree is entered only if there is an x-range overlap. maxXinRectangle(6,12,7). Time is O(log k).

minYinXrange(xL,xR) minYinXrange(6,10). Time is O(log k). 12,1 [0,16) 5,8 [0,8) 6,9 [4,8) [8,16) 11,5 2,12 [0,4) [12,16) 14,6 Check if root is a candidate (I.e., is it in the x-range). If so, discontinue search. Otherwise, search left subtree if x-range has overlap. Also search right subtree if x-range has overlap. Take better of the up to 2 points found. minYinXrange(6,10). Time is O(log k).

enumerateRectangle(xL,xR,yT) 12,1 [0,16) 5,8 [0,8) 6,9 [4,8) [8,16) 11,5 2,12 [0,4) [12,16) 14,6 If root y-value is > yT quit. Check if root is in the rectangle. Search left and right subtrees (provided there is an x-range overlap) for additional points. enumerateRectangle(6,12,8). Time is O(log k + s), where s is #points in rectangle.