Maintaining Dynamic Tree with Min Subject to Constraints

Slides:



Advertisements
Similar presentations
COL 106 Shweta Agrawal and Amit Kumar
Advertisements

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.
Topic 23 Red Black Trees "People in every direction No words exchanged No time to exchange And all the little ants are marching Red and black antennas.
Binary Trees, Binary Search Trees CMPS 2133 Spring 2008.
Binary Trees, Binary Search Trees COMP171 Fall 2006.
AA Trees another alternative to AVL trees. Balanced Binary Search Trees A Binary Search Tree (BST) of N nodes is balanced if height is in O(log N) A balanced.
Balanced Binary Search Trees
CS 171: Introduction to Computer Science II
Lec 15 April 9 Topics: l binary Trees l expression trees Binary Search Trees (Chapter 5 of text)
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!
1 abstract containers hierarchical (1 to many) graph (many to many) first ith last sequence/linear (1 to 1) set.
Binary Trees Chapter 6.
Advanced Data Structures and Algorithms COSC-600 Lecture presentation-6.
Chapter 6 Binary Trees. 6.1 Trees, Binary Trees, and Binary Search Trees Linked lists usually are more flexible than arrays, but it is difficult to use.
Binary Trees, Binary Search Trees RIZWAN REHMAN CENTRE FOR COMPUTER STUDIES DIBRUGARH UNIVERSITY.
CSIT 402 Data Structures II
Chapter 13 B Advanced Implementations of Tables – Balanced BSTs.
Announcements Exam Friday. More Physical Storage Lecture 10.
Data Structures Haim Kaplan and Uri Zwick November 2012 Lecture 3 Dynamic Sets / Dictionaries Binary Search Trees.
Lec 15 Oct 18 Binary Search Trees (Chapter 5 of text)
CSE 250 September 29 – October 3, A NNOUNCEMENTS Homework 4 due 10/5 Project 1 posted for 10/6 Exam 2 10/8 No classes meet 10/9 Project 1 due 10/26.
Lecture 11COMPSCI.220.FS.T Balancing an AVLTree Two mirror-symmetric pairs of cases to rebalance the tree if after the insertion of a new key to.
Tree Traversals, TreeSort 20 February Expression Tree Leaves are operands Interior nodes are operators A binary tree to represent (A - B) + C.
Lecture 9COMPSCI.220.FS.T Lower Bound for Sorting Complexity Each algorithm that sorts by comparing only pairs of elements must use at least 
Lecture 10COMPSCI.220.FS.T Binary Search Tree BST converts a static binary search into a dynamic binary search allowing to efficiently insert and.
1 Binary Search Trees  Average case and worst case Big O for –insertion –deletion –access  Balance is important. Unbalanced trees give worse than log.
Review for Exam 2 Topics covered: –Recursion and recursive functions –General rooted trees –Binary Search Trees (BST) –Splay Tree –RB Tree –K-D Trees For.
ITEC 2620M Introduction to Data Structures Instructor: Prof. Z. Yang Course Website: ec2620m.htm Office: TEL 3049.
Binary Search Trees What is a binary search tree?
Lecture 15 Nov 3, 2013 Height-balanced BST Recall:
AA Trees.
Lec 13 Oct 17, 2011 AVL tree – height-balanced tree Other options:
CSCE 3110 Data Structures & Algorithm Analysis
Red-Black Tree Neil Tang 02/07/2008
Red-Black Tree Neil Tang 02/04/2010
BCA-II Data Structure Using C
G64ADS Advanced Data Structures
Red-Black Trees v z Red-Black Trees Red-Black Trees
CSCE 3110 Data Structures & Algorithm Analysis
Red Black Trees
Lecture 16 Multiway Search Trees
Red-Black Trees v z Red-Black Trees 1 Red-Black Trees
Binary Search Tree Chapter 10.
Lecture 22 Binary Search Trees Chapter 10 of textbook
abstract containers sequence/linear (1 to 1) hierarchical (1 to many)
Chapter 16 Tree Implementations
CS200: Algorithms Analysis
Tree data structure.
Design and Analysis of Algorithms
Binary Trees, Binary Search Trees
Chapter 6 Transform and Conquer.
Lec 12 March 9, 11 Mid-term # 1 (March 21?)
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
CS202 - Fundamental Structures of Computer Science II
Red-Black Trees v z Red-Black Trees Red-Black Trees
Tree data structure.
Fundamental Structures of Computer Science
Random inserting into a B+ Tree
CS6045: Advanced Algorithms
Topics covered (since exam 1, excluding PQ):
Binary Trees, Binary Search Trees
Heaps © 2014 Goodrich, Tamassia, Goldwasser Heaps Heaps
Binary SearchTrees [CLRS] – Chap 12.
Lecture 10 Oct 1, 2012 Complete BST deletion Height-balanced BST
Goals Design decisions Design Insertion
Binary Search Trees Comp 122, Spring 2004.
Binary Trees, Binary Search Trees
Binary Search Trees < > = Dictionaries
Presentation transcript:

Maintaining Dynamic Tree with Min Subject to Constraints Data Structures 2003 CS TAU

Multi Criteria Representation Consider a set of elements Each element is equipped with two keys (values): K1, K2 For simplicity: Assume each key appears at most once. Want to support: Insert(k1, k2), delete(k1,k2), find_min(k1), find_min(k2) Implementation: Double data structure, with pointers between the structures. 2/24/2019 Min s.t. Constraints, Hanoch Levy CS, TAU

Min s.t. Constraints, Hanoch Levy CS, TAU Example For each person: height + Grade Two 2-3 trees, HEIGHT, GRADE Insert in both Findmin on either Pointers between the two for member, deletions GRADE 8 50 81 97 HEIGHT 185 160 172 173 2/24/2019 Min s.t. Constraints, Hanoch Levy CS, TAU

Maintaining Minimum (Max) subject to constraint Consider a set of elements Each element is equipped with two keys (values): K1, K2 Want to support: Insert Delete Find MIN(K1) subject to K2 > k (or MAX) 2/24/2019 Min s.t. Constraints, Hanoch Levy CS, TAU

Min s.t. Constraints, Hanoch Levy CS, TAU Example Store student records Each student has GRADE, HEIGHT Assume all GRADEs are unique. Want: Insert (g,h): Insert the pair Delete (g,h): Delete the pair x= FINDMAX (height): FindMAX(grade) s.t. H<=h (find the maximal grade of the short students). 2/24/2019 Min s.t. Constraints, Hanoch Levy CS, TAU

Dual 2-3 Tree with leaf linked lists and mutual pointers Problematic Easy to find the set of students whose height >= h Finding the max grade on this is O(N) GRADE 8 50 81 97 HEIGHT 185 160 172 173 2/24/2019 Min s.t. Constraints, Hanoch Levy CS, TAU

Efficient Data Structure Want: minimum grade subject to height >=h E.g: height >= 165 Store constraint on a search tree (2-3 tree) The red recursion allows us to identify all the sub-trees that obey the constraint 172 173 185 162 165 169 189 160 172 173 185 HEIGHT 162 165 169 189 2/24/2019 Min s.t. Constraints, Hanoch Levy CS, TAU

Representing the Function minimized (grade) 172 173 185 162 165 169 189 160 Each leaf marked with its GRADE (not sorted!) Internal nodes keep the minimum grade of the sub-tree. Algorithm: Bring up black values which are roots of red trees. When two values brought up – take min and bring up 60 80 75 50 90 93 60 80 75 95 50 2/24/2019 Min s.t. Constraints, Hanoch Levy CS, TAU

Alternative Description of algorithm (recursive) 90 93 60 80 75 95 50 172 173 185 162 165 169 189 160 Children of node can be of 3 “types”: Black (no node in sub-tree is relevant) Red (all nodes in sub-tree are relevant) “gray” (some nodes in sub-tree are relevant) Algorithm Red: bring its value Black: disregard Gray: bring value computed recursively 2/24/2019 Min s.t. Constraints, Hanoch Levy CS, TAU

Min s.t. Constraints, Hanoch Levy CS, TAU Complexity 90 93 60 80 75 95 50 172 173 185 162 165 169 189 160 Each node has at most one gray Red – O(1) Black – O(1) Gray – continue deeper  path of gray is of length O(h) = O(log N).  Over all complexity for operation O(log N) 2/24/2019 Min s.t. Constraints, Hanoch Levy CS, TAU