Fundamental Algorithms
|
|
- Aubrie Newton
- 6 years ago
- Views:
Transcription
1 Fundamental Algithms Chapter 4: AVL Trees Jan Křetínský Winter 2016/17 Chapter 4: AVL Trees, Winter 2016/17 1
2 Part I AVL Trees (Adelson-Velsky and Landis, 1962) Chapter 4: AVL Trees, Winter 2016/17 2
3 Binary Search Trees Summary Compleity of Searching: wst-case compleity depends on height of the search trees O(log n) f balanced trees Inserting and Deleting: insertion and deletion might change balance of trees question: how epensie is re-balancing? Test: Inserting/Deleting into a (fully) balanced tree strict balancing (unifm depth f all leaes) too strict Chapter 4: AVL Trees, Winter 2016/17 3
4 AVL-Trees Definition AVL-trees are binary search trees that fulfill the following balance condition. F eery node height(left sub-tree()) height(right sub-tree()) 1. Lemma An AVL-tree of height h contains at least F h+2 1 and at most 2 internal nodes, where F n is the n-th Fibonacci number (F 0 = 0, F 1 = 1), and the height is the maimal number of edges from the root to an (empty) dummy leaf. Chapter 4: AVL Trees, Winter 2016/17 4
5 AVL trees Proof. The upper bound is clear, as a binary tree of height h can only contain h 1 2 j = 2 internal nodes. j=0 Chapter 4: AVL Trees, Winter 2016/17 5
6 AVL trees Proof (cont.) Induction (base cases): 1. an AVL-tree of height h = 1 contains at least one internal node, 1 F 3 1 = 2 1 = an AVL tree of height h = 2 contains at least two internal nodes, 2 F 4 1 = 3 1 = 2 Chapter 4: AVL Trees, Winter 2016/17 6
7 Induction step: An AVL-tree of height h 2 of minimal size has a root with sub-trees of height and h 2, respectiely. Both sub-trees hae minimal node number. h 2 Let g h := 1 + minimal size of AVL-tree of height h. Then g 1 = 2 = F 3 g 2 = 3 = F 4 g = 1 + g h g h 2 1, hence g h = g h 1 + g h 2 = F h+2
8 AVL-Tress An AVL-tree of height h contains at least F h+2 1 internal nodes. Since ( n + 1 F h+2 = Ω 1 + ) h 5, 2 we get ( n Ω 1 + ) h 5, 2 and, hence, h = O(log n). Chapter 4: AVL Trees, Winter 2016/17 8
9 AVL-trees We need to maintain the balance condition through rotations. F this we ste in eery internal tree-node the balance of the node. Let denote a tree node with left child c l and right child c r. balance[] := height(t cl ) height(t cr ), where T cl and T cr, are the sub-trees rooted at c l and c r, respectiely. Chapter 4: AVL Trees, Winter 2016/17 9
10 Rotations The properties will be maintained through rotations: z LeftRotate() z A RightRotate(z) C B C A B Chapter 4: AVL Trees, Winter 2016/17 10
11 Double Rotations z y D A B C LeftRotate(y) RightRotate() z y y z D DoubleRightRotate() A B C A B C D
12 AVL-trees: Insert Insert like in a binary search tree. Let w denote the parent of the newly inserted node. One of the following cases holds: w w w w a a bal(w) = 1 bal(w) = 0 bal(w) = 0 bal(w) = 1 If bal[w] 0, T w has changed height; the balance-constraint may be iolated at ancests of w. Call AVL-fi-up-insert(parent[w]) to reste the balance-condition. Chapter 4: AVL Trees, Winter 2016/17 12
13 AVL-trees: Insert Inariant at the beginning of AVL-fi-up-insert(): 1. The balance constraints hold at all descendants of. 2. A node has been inserted into T c, where c is either the right left child of. 3. T c has increased its height by one (otw. we would already hae abted the fi-up procedure). 4. The balance at node c fulfills balance[c] { 1, 1}. This holds because if the balance of c is 0, then T c did not change its height, and the whole procedure would hae been abted in the preious step. Chapter 4: AVL Trees, Winter 2016/17 13
14 AVL-trees: Insert Algithm 1 AVL-fi-up-insert() 1: if balance[] { 2, 2} then DoRotationInsert(); 2: if balance[] {0} return; 3: if parent[] = null return; 4: compute balance of parent[]; 5: AVL-fi-up-insert(parent[]); We will show that the aboe procedure is crect, and that it will do at most one rotation. Chapter 4: AVL Trees, Winter 2016/17 14
15 AVL-trees: Insert Algithm 2 DoRotationInsert() 1: if balance[] = 2 then // insert in right sub-tree 2: if balance[right[]] = 1 then 3: LeftRotate(); 4: else 5: DoubleLeftRotate(); 6: else // insert in left sub-tree 7: if balance[left[]] = 1 then 8: RightRotate(); 9: else 10: DoubleRightRotate(); Chapter 4: AVL Trees, Winter 2016/17 15
16 AVL-trees: Insert It is clear that the inariants f the fi-up routine hold as long as no rotations hae been done. We hae to show that after doing one rotation all balance constraints are fulfilled. We show that after doing a rotation at : fulfills balance condition. All children of still fulfill the balance condition. The height of T is the same as befe the insert-operation took place. We only look at the case where the insert happened into the right sub-tree of. The other case is symmetric. Chapter 4: AVL Trees, Winter 2016/17 16
17 AVL-trees: Insert We hae the following situation: h + 1 The right sub-tree of has increased its height which results in a balance of 2 at. Befe the insertion the height of T was h + 1. Chapter 4: AVL Trees, Winter 2016/17 17
18 Case 1: balance[right[]] = 1 We do a left rotation at LeftRotate() h h Now, the subtree has height h + 1 as befe the insertion. Hence, we do not need to continue. Chapter 4: AVL Trees, Winter 2016/17 18
19 Case 2: balance[right[]] = 1 y RightRotate() y h 2 h 2 h 2 h 2 DoubleLeftRotate() y LeftRotate() Height is h + 1, as befe the insert. h 2 h 2
20 AVL-trees: Delete Delete like in a binary search tree. Let denote the parent of the node that has been spliced out. The balance-constraint may be iolated at, at ancests of, as a sub-tree of a child of has reduced its height. Initially, the node c the new root in the sub-tree that has changed is either a dummy leaf a node with two dummy leafs as children. c Case 1 Case 2 In both cases bal[c] = 0. Call AVL-fi-up-delete() to reste the balance-condition. Chapter 4: AVL Trees, Winter 2016/17 20
21 AVL-trees: Delete Inariant at the beginning AVL-fi-up-delete(): 1. The balance constraints holds at all descendants of. 2. A node has been deleted from T c, where c is either the right left child of. 3. T c has decreased its height by one. 4. The balance at the node c fulfills balance[c] = 0. This holds because if the balance of c is in { 1, 1}, then T c did not change its height, and the whole procedure would hae been abted in the preious step. Chapter 4: AVL Trees, Winter 2016/17 21
22 AVL-trees: Delete Algithm 3 AVL-fi-up-delete() 1: if balance[] { 2, 2} then DoRotationDelete(); 2: if balance[] { 1, 1} return; 3: if parent[] = null return; 4: compute balance of parent[]; 5: AVL-fi-up-delete(parent[]); We will show that the aboe procedure is crect. Howeer, f the case of a delete there may be a logarithmic number of rotations. Chapter 4: AVL Trees, Winter 2016/17 22
23 AVL-trees: Delete Algithm 4 DoRotationDelete() 1: if balance[] = 2 then // deletion in left sub-tree 2: if balance[right[]] {0, 1} then 3: LeftRotate(); 4: else 5: DoubleLeftRotate(); 6: else // deletion in right sub-tree 7: if balance[left[]] = {0, 1} then 8: RightRotate(); 9: else 10: DoubleRightRotate(); Chapter 4: AVL Trees, Winter 2016/17 23
24 AVL-trees: Delete It is clear that the inariants f the fi-up routine hold as long as no rotations hae been done. We show that after doing a rotation at : fulfills the balance condition. All children of still fulfill the balance condition. If now balance[] { 1, 1} we can stop as the height of T is the same as befe the deletion. We only look at the case where the deleted node was in the right sub-tree of. The other case is symmetric. Chapter 4: AVL Trees, Winter 2016/17 24
25 AVL-trees: Delete We hae the following situation: h + 1 h The right sub-tree of has decreased its height which results in a balance of 2 at. Befe the deletion the height of T was h + 2. Chapter 4: AVL Trees, Winter 2016/17 25
26 Case 1: balance[left[]] {0, 1} RightRotate() h h h h If the middle subtree has height h the whole tree has height h + 2 as befe the deletion. The iteration stops as the balance at the root is non-zero. If the middle subtree has height the whole tree has decreased its height from h + 2 to h + 1. We do continue the fi-up procedure as the balance at the root is zero.
27 Case 2: balance[left[]] = 1 y y LeftRotate() h 2 h 2 h 2 h 2 y RightRotate() Sub-tree has height h + 1, i.e., it has shrunk. The balance at y is zero. We continue the iteration. DoubleRightRotate() h 2 h 2
7.3 AVL-Trees. Definition 15. Lemma 16. AVL-trees are binary search trees that fulfill the following balance condition.
Definition 15 AVL-trees are binary search trees that fulfill the following balance condition. F eery node height(left sub-tree()) height(right sub-tree()) 1. Lemma 16 An AVL-tree of height h contains at
More information7 Dictionary. 7.1 Binary Search Trees. Binary Search Trees: Searching. 7.1 Binary Search Trees
7 Dictionary Dictionary: S.insert(): Insert an element. S.delete(): Delete the element pointed to by. 7.1 Binary Search Trees An (internal) binary search tree stores the elements in a binary tree. Each
More information7 Dictionary. EADS c Ernst Mayr, Harald Räcke 109
7 Dictionary Dictionary: S.insert(x): Insert an element x. S.delete(x): Delete the element pointed to by x. S.search(k): Return a pointer to an element e with key[e] = k in S if it exists; otherwise return
More informationThe null-pointers in a binary search tree are replaced by pointers to special null-vertices, that do not carry any object-data
Definition 1 A red black tree is a balanced binary search tree in which each internal node has two children. Each internal node has a color, such that 1. The root is black. 2. All leaf nodes are black.
More information7 Dictionary. Harald Räcke 125
7 Dictionary Dictionary: S. insert(x): Insert an element x. S. delete(x): Delete the element pointed to by x. S. search(k): Return a pointer to an element e with key[e] = k in S if it exists; otherwise
More information16. Binary Search Trees. [Ottman/Widmayer, Kap. 5.1, Cormen et al, Kap ]
418 16. Binary Search Trees [Ottman/Widmayer, Kap. 5.1, Cormen et al, Kap. 12.1-12.3] 419 Dictionary implementation Hashing: implementation of dictionaries with expected very fast access times. Disadvantages
More information16. Binary Search Trees. [Ottman/Widmayer, Kap. 5.1, Cormen et al, Kap ]
423 16. Binary Search Trees [Ottman/Widmayer, Kap. 5.1, Cormen et al, Kap. 12.1-12.3] Dictionary implementation 424 Hashing: implementation of dictionaries with expected very fast access times. Disadvantages
More informationAVL Trees. Manolis Koubarakis. Data Structures and Programming Techniques
AVL Trees Manolis Koubarakis 1 AVL Trees We will now introduce AVL trees that have the property that they are kept almost balanced but not completely balanced. In this way we have O(log n) search time
More informationCS 151. Red Black Trees & Structural Induction. Thursday, November 1, 12
CS 151 Red Black Trees & Structural Induction 1 Announcements Majors fair tonight 4:30-6:30pm in the Root Room in Carnegie. Come and find out about the CS major, or some other major. Winter Term in CS
More informationOrdered Dictionary & Binary Search Tree
Ordered Dictionary & Binary Search Tree Finite map from keys to values, assuming keys are comparable (). insert(k, v) lookup(k) aka find: the associated value if any delete(k) (Ordered set: No values;
More informationSearch Trees. Chapter 10. CSE 2011 Prof. J. Elder Last Updated: :52 AM
Search Trees Chapter 1 < 6 2 > 1 4 = 8 9-1 - Outline Ø Binary Search Trees Ø AVL Trees Ø Splay Trees - 2 - Outline Ø Binary Search Trees Ø AVL Trees Ø Splay Trees - 3 - Binary Search Trees Ø A binary search
More informationData Structures and Algorithms " Search Trees!!
Data Structures and Algorithms " Search Trees!! Outline" Binary Search Trees! AVL Trees! (2,4) Trees! 2 Binary Search Trees! "! < 6 2 > 1 4 = 8 9 Ordered Dictionaries" Keys are assumed to come from a total
More informationSearch Trees. EECS 2011 Prof. J. Elder Last Updated: 24 March 2015
Search Trees < 6 2 > 1 4 = 8 9-1 - Outline Ø Binary Search Trees Ø AVL Trees Ø Splay Trees - 2 - Learning Outcomes Ø From this lecture, you should be able to: q Define the properties of a binary search
More informationPart III. Data Structures. Abstract Data Type. Dynamic Set Operations. Dynamic Set Operations
Abstract Data Type Part III Data Structures An abstract data type (ADT) is defined by an interface of operations or methods that can be performed and that have a defined behavior. The data types in this
More informationAssignment 5: Solutions
Comp 21: Algorithms and Data Structures Assignment : Solutions 1. Heaps. (a) First we remove the minimum key 1 (which we know is located at the root of the heap). We then replace it by the key in the position
More information16. Binary Search Trees
Dictionary imlementation 16. Binary Search Trees [Ottman/Widmayer, Ka..1, Cormen et al, Ka. 1.1-1.] Hashing: imlementation of dictionaries with exected very fast access times. Disadvantages of hashing:
More informationCS 310: AVL Trees. Chris Kauffman. Week 13-1
CS 310: AVL Trees Chris Kauffman Week 13-1 BSTs: Our Focus AVL and Red Black Trees are complex DSs Focus on high-level flavor You Are Responsible For Principles Pictures What principle is violated? How
More information4.8 Huffman Codes. These lecture slides are supplied by Mathijs de Weerd
4.8 Huffman Codes These lecture slides are supplied by Mathijs de Weerd Data Compression Q. Given a text that uses 32 symbols (26 different letters, space, and some punctuation characters), how can we
More information16. Binary Search Trees
Dictionary imlementation 16. Binary Search Trees [Ottman/Widmayer, Ka..1, Cormen et al, Ka. 12.1-12.] Hashing: imlementation of dictionaries with exected very fast access times. Disadvantages of hashing:
More informationFundamental Algorithms
Fundamental Algorithms Chapter 5: Searching Michael Bader Winter 2014/15 Chapter 5: Searching, Winter 2014/15 1 Searching Definition (Search Problem) Input: a sequence or set A of n elements (objects)
More informationBinary Search Trees. Motivation
Binary Search Trees Motivation Searching for a particular record in an unordered list takes O(n), too slow for large lists (databases) If the list is ordered, can use an array implementation and use binary
More informationOutline. Computer Science 331. Cost of Binary Search Tree Operations. Bounds on Height: Worst- and Average-Case
Outline Computer Science Average Case Analysis: Binary Search Trees Mike Jacobson Department of Computer Science University of Calgary Lecture #7 Motivation and Objective Definition 4 Mike Jacobson (University
More informationChapter 5 Data Structures Algorithm Theory WS 2017/18 Fabian Kuhn
Chapter 5 Data Structures Algorithm Theory WS 2017/18 Fabian Kuhn Priority Queue / Heap Stores (key,data) pairs (like dictionary) But, different set of operations: Initialize-Heap: creates new empty heap
More informationFibonacci Heaps These lecture slides are adapted from CLRS, Chapter 20.
Fibonacci Heaps These lecture slides are adapted from CLRS, Chapter 20. Princeton University COS 4 Theory of Algorithms Spring 2002 Kevin Wayne Priority Queues Operation mae-heap insert find- delete- union
More informationEach internal node v with d(v) children stores d 1 keys. k i 1 < key in i-th sub-tree k i, where we use k 0 = and k d =.
7.5 (a, b)-trees 7.5 (a, b)-trees Definition For b a an (a, b)-tree is a search tree with the following properties. all leaves have the same distance to the root. every internal non-root vertex v has at
More informationINF2220: algorithms and data structures Series 1
Universitetet i Oslo Institutt for Informatikk I. Yu, D. Karabeg INF2220: algorithms and data structures Series 1 Topic Function growth & estimation of running time, trees (Exercises with hints for solution)
More informationCS 240 Data Structures and Data Management. Module 4: Dictionaries
CS 24 Data Structures and Data Management Module 4: Dictionaries A. Biniaz A. Jamshidpey É. Schost Based on lecture notes by many previous cs24 instructors David R. Cheriton School of Computer Science,
More informationNetwork Flow Problems Luis Goddyn, Math 408
Network Flow Problems Luis Goddyn, Math 48 Let D = (V, A) be a directed graph, and let s, t V (D). For S V we write δ + (S) = {u A : u S, S} and δ (S) = {u A : u S, S} for the in-arcs and out-arcs of S
More informationDictionary: an abstract data type
2-3 Trees 1 Dictionary: an abstract data type A container that maps keys to values Dictionary operations Insert Search Delete Several possible implementations Balanced search trees Hash tables 2 2-3 trees
More informationAnalysis of Algorithms. Outline 1 Introduction Basic Definitions Ordered Trees. Fibonacci Heaps. Andres Mendez-Vazquez. October 29, Notes.
Analysis of Algorithms Fibonacci Heaps Andres Mendez-Vazquez October 29, 2015 1 / 119 Outline 1 Introduction Basic Definitions Ordered Trees 2 Binomial Trees Example 3 Fibonacci Heap Operations Fibonacci
More informationDictionary: an abstract data type
2-3 Trees 1 Dictionary: an abstract data type A container that maps keys to values Dictionary operations Insert Search Delete Several possible implementations Balanced search trees Hash tables 2 2-3 trees
More information8 Priority Queues. 8 Priority Queues. Prim s Minimum Spanning Tree Algorithm. Dijkstra s Shortest Path Algorithm
8 Priority Queues 8 Priority Queues A Priority Queue S is a dynamic set data structure that supports the following operations: S. build(x 1,..., x n ): Creates a data-structure that contains just the elements
More informationData Structures and and Algorithm Xiaoqing Zheng
Data Structures and Algorithm Xiaoqing Zheng zhengxq@fudan.edu.cn Trees (max heap) 1 16 2 3 14 10 4 5 6 7 8 7 9 3 8 9 10 2 4 1 PARENT(i) return i /2 LEFT(i) return 2i RIGHT(i) return 2i +1 16 14 10 8 7
More informationBinary Search Trees. Lecture 29 Section Robb T. Koether. Hampden-Sydney College. Fri, Apr 8, 2016
Binary Search Trees Lecture 29 Section 19.2 Robb T. Koether Hampden-Sydney College Fri, Apr 8, 2016 Robb T. Koether (Hampden-Sydney College) Binary Search Trees Fri, Apr 8, 2016 1 / 40 1 Binary Search
More informationAlgorithms Theory. 08 Fibonacci Heaps
Algorithms Theory 08 Fibonacci Heaps Prof. Dr. S. Albers Priority queues: operations Priority queue Q Operations: Q.initialize(): initializes an empty queue Q Q.isEmpty(): returns true iff Q is empty Q.insert(e):
More informationFaster exact computation of rspr distance
DOI 10.1007/s10878-013-9695-8 Faster exact comptation of rspr distance Zhi-Zhong Chen Ying Fan Lsheng Wang Springer Science+Bsiness Media New Yk 2013 Abstract De to hybridiation eents in eoltion, stdying
More informationChapter 10 Search Structures
Chapter 1 Search Structures 1 1.2 AVL Trees : 동기 Objective : maintain binary search tree structure for O(log n) access time with dynamic changes of identifiers (i.e., elements) in the tree. JULY APR AUG
More informationAdvanced Implementations of Tables: Balanced Search Trees and Hashing
Advanced Implementations of Tables: Balanced Search Trees and Hashing Balanced Search Trees Binary search tree operations such as insert, delete, retrieve, etc. depend on the length of the path to the
More informationAVL Trees. Properties Insertion. October 17, 2017 Cinda Heeren / Geoffrey Tien 1
AVL Trees Properties Insertion October 17, 2017 Cinda Heeren / Geoffrey Tien 1 BST rotation g g e h b h b f i a e i a c c f d d Rotations preserve the in-order BST property, while altering the tree structure
More informationWeight-balanced Binary Search Trees
Weight-balanced Binary Search Trees Weight-balanced BSTs are one way to achieve O(lg n) tree height. For this purpose, weight means size+1: weight(x) = size(x) + 1. A weight-balanced BST: is a binary search
More informationpast balancing schemes require maintenance of balance info at all times, are aggresive use work of searches to pay for work of rebalancing
1 Splay Trees Sleator and Tarjan, Self Adjusting Binary Search Trees JACM 32(3) 1985 The claim planning ahead. But matches previous idea of being lazy, letting potential build up, using it to pay for expensive
More informationGraphs and Trees Binary Search Trees AVL-Trees (a,b)-trees Splay-Trees. Search Trees. Tobias Lieber. April 14, 2008
Search Trees Tobias Lieber April 14, 2008 Tobias Lieber Search Trees April 14, 2008 1 / 57 Graphs and Trees Binary Search Trees AVL-Trees (a,b)-trees Splay-Trees Tobias Lieber Search Trees April 14, 2008
More informationAn Explicit Lower Bound of 5n o(n) for Boolean Circuits
An Eplicit Lower Bound of 5n o(n) for Boolean Circuits Kazuo Iwama, Oded Lachish, Hiroki Morizumi, and Ran Raz Graduate School of Informatics, Kyoto Uniersity, Kyoto, JAPAN {iwama, morizumi}@kuis.kyoto-u.ac.jp
More informationWeight-balanced Binary Search Trees
Weight-balanced Binary Search Trees Weight-balanced BSTs are one way to achieve O(lg n) tree height. A weight-balanced BST: is a binary search tree at every node v: Equivalently: ( weight means size+1)
More informationICS141: Discrete Mathematics for Computer Science I
ICS141: Discrete Mathematics for Computer Science I Dept. Information & Computer Sci., Jan Stelovsky based on slides by Dr. Baek and Dr. Still Originals by Dr. M. P. Frank and Dr. J.L. Gross Provided by
More informationPriority queues implemented via heaps
Priority queues implemented via heaps Comp Sci 1575 Data s Outline 1 2 3 Outline 1 2 3 Priority queue: most important first Recall: queue is FIFO A normal queue data structure will not implement a priority
More informationProblem. Problem Given a dictionary and a word. Which page (if any) contains the given word? 3 / 26
Binary Search Introduction Problem Problem Given a dictionary and a word. Which page (if any) contains the given word? 3 / 26 Strategy 1: Random Search Randomly select a page until the page containing
More informationsearching algorithms
searching algorithms learning objectives algorithms your software system software hardware learn what the searching problem is about learn two algorithms for solving this problem learn the importance of
More information7 Dictionary. Ernst Mayr, Harald Räcke 126
7 Dictionary Dictionary: S. insert(x): Insert an element x. S. delete(x): Delete the element pointed to by x. S. search(k): Return a pointer to an element e with key[e] = k in S if it exists; otherwise
More informationAlgorithm for exact evaluation of bivariate two-sample Kolmogorov-Smirnov statistics in O(nlogn) time.
Algorithm for exact evaluation of bivariate two-sample Kolmogorov-Smirnov statistics in O(nlogn) time. Krystian Zawistowski January 3, 2019 Abstract We propose an O(nlogn) algorithm for evaluation of bivariate
More information1. [10 marks] Consider the following two algorithms that find the two largest elements in an array A[1..n], where n >= 2.
CSC 6 H5S Homework Assignment # 1 Spring 010 Worth: 11% Due: Monday February 1 (at class) For each question, please write up detailed answers carefully. Make sure that you use notation and terminology
More informationCS361 Homework #3 Solutions
CS6 Homework # Solutions. Suppose I have a hash table with 5 locations. I would like to know how many items I can store in it before it becomes fairly likely that I have a collision, i.e., that two items
More informationQuiz 1 Solutions. Problem 2. Asymptotics & Recurrences [20 points] (3 parts)
Introduction to Algorithms October 13, 2010 Massachusetts Institute of Technology 6.006 Fall 2010 Professors Konstantinos Daskalakis and Patrick Jaillet Quiz 1 Solutions Quiz 1 Solutions Problem 1. We
More informationFibonacci (Min-)Heap. (I draw dashed lines in place of of circular lists.) 1 / 17
Fibonacci (Min-)Heap A forest of heap-order trees (parent priority child priority). Roots in circular doubly-linked list. Pointer to minimum-priority root. Siblings in circular doubly-linked list; parent
More informationCS Data Structures and Algorithm Analysis
CS 483 - Data Structures and Algorithm Analysis Lecture VII: Chapter 6, part 2 R. Paul Wiegand George Mason University, Department of Computer Science March 22, 2006 Outline 1 Balanced Trees 2 Heaps &
More informationDynamic Programming on Trees. Example: Independent Set on T = (V, E) rooted at r V.
Dynamic Programming on Trees Example: Independent Set on T = (V, E) rooted at r V. For v V let T v denote the subtree rooted at v. Let f + (v) be the size of a maximum independent set for T v that contains
More informationNotes on Logarithmic Lower Bounds in the Cell Probe Model
Notes on Logarithmic Lower Bounds in the Cell Probe Model Kevin Zatloukal November 10, 2010 1 Overview Paper is by Mihai Pâtraşcu and Erik Demaine. Both were at MIT at the time. (Mihai is now at AT&T Labs.)
More informationProblem: Data base too big to fit memory Disk reads are slow. Example: 1,000,000 records on disk Binary search might take 20 disk reads
B Trees Problem: Data base too big to fit memory Disk reads are slow Example: 1,000,000 records on disk Binary search might take 20 disk reads Disk reads are done in blocks Example: One block read can
More informationSplay Trees. CMSC 420: Lecture 8
Splay Trees CMSC 420: Lecture 8 AVL Trees Nice Features: - Worst case O(log n) performance guarantee - Fairly simple to implement Problem though: - Have to maintain etra balance factor storage at each
More informationLecture 5: Splay Trees
15-750: Graduate Algorithms February 3, 2016 Lecture 5: Splay Trees Lecturer: Gary Miller Scribe: Jiayi Li, Tianyi Yang 1 Introduction Recall from previous lecture that balanced binary search trees (BST)
More informationChapter 5 Arrays and Strings 5.1 Arrays as abstract data types 5.2 Contiguous representations of arrays 5.3 Sparse arrays 5.4 Representations of
Chapter 5 Arrays and Strings 5.1 Arrays as abstract data types 5.2 Contiguous representations of arrays 5.3 Sparse arrays 5.4 Representations of strings 5.5 String searching algorithms 0 5.1 Arrays as
More informationCMPUT 675: Approximation Algorithms Fall 2014
CMPUT 675: Approximation Algorithms Fall 204 Lecture 25 (Nov 3 & 5): Group Steiner Tree Lecturer: Zachary Friggstad Scribe: Zachary Friggstad 25. Group Steiner Tree In this problem, we are given a graph
More informationS(b)-Trees: an Optimal Balancing of Variable Length Keys. Konstantin V. Shvachko
S(b)-Trees: an Optimal Balancing of Variable Length Keys Konstantin V. Shvachko 2 Dynamic Dictionaries Let K be a set of dictionary elements, called keys. For any finite subset D of K and for any key k
More informationBinary Decision Diagrams. Graphs. Boolean Functions
Binary Decision Diagrams Graphs Binary Decision Diagrams (BDDs) are a class of graphs that can be used as data structure for compactly representing boolean functions. BDDs were introduced by R. Bryant
More informationB- TREE. Michael Tsai 2017/06/06
B- TREE Michael Tsai 2017/06/06 2 B- Tree Overview Balanced search tree Very large branching factor Height = O(log n), but much less than that of RB tree Usage: Large amount of data to be stored - - Partially
More informationMA008/MIIZ01 Design and Analysis of Algorithms Lecture Notes 3
MA008 p.1/37 MA008/MIIZ01 Design and Analysis of Algorithms Lecture Notes 3 Dr. Markus Hagenbuchner markus@uow.edu.au. MA008 p.2/37 Exercise 1 (from LN 2) Asymptotic Notation When constants appear in exponents
More informationSlides for CIS 675. Huffman Encoding, 1. Huffman Encoding, 2. Huffman Encoding, 3. Encoding 1. DPV Chapter 5, Part 2. Encoding 2
Huffman Encoding, 1 EECS Slides for CIS 675 DPV Chapter 5, Part 2 Jim Royer October 13, 2009 A toy example: Suppose our alphabet is { A, B, C, D }. Suppose T is a text of 130 million characters. What is
More information5. Biconnected Components of A Graph
5. Biconnected Components of A Graph If one city s airport is closed by bad eather, can you still fly beteen any other pair of cities? If one computer in a netork goes don, can a message be sent beteen
More information25. Minimum Spanning Trees
695 25. Minimum Spanning Trees Motivation, Greedy, Algorithm Kruskal, General Rules, ADT Union-Find, Algorithm Jarnik, Prim, Dijkstra, Fibonacci Heaps [Ottman/Widmayer, Kap. 9.6, 6.2, 6.1, Cormen et al,
More information25. Minimum Spanning Trees
Problem Given: Undirected, weighted, connected graph G = (V, E, c). 5. Minimum Spanning Trees Motivation, Greedy, Algorithm Kruskal, General Rules, ADT Union-Find, Algorithm Jarnik, Prim, Dijkstra, Fibonacci
More informationBinary Search Trees. Dictionary Operations: Additional operations: find(key) insert(key, value) erase(key)
Binary Search Trees Dictionary Operations: find(key) insert(key, value) erase(key) Additional operations: ascend() get(index) (indexed binary search tree) delete(index) (indexed binary search tree) Complexity
More informationPhylogenetic Reconstruction with Insertions and Deletions
Phylogenetic Reconstruction with Insertions and Deletions [Full Version] Alexandr Andoni Mark Braverman Princeton University Avinatan Hassidim Bar-Ilan University October 19, 2014 Abstract We study phylogenetic
More informationsearch trees. It is therefore important to obtain as full an understanding of the issue as possible. Additionally, there are practical applications fo
AVL Trees with Relaxed Balance Kim S. Larsen y University of Southern Denmar, Odense z Abstract The idea of relaxed balance is to uncouple the rebalancing in search trees from the updating in order to
More informationHW #4. (mostly by) Salim Sarımurat. 1) Insert 6 2) Insert 8 3) Insert 30. 4) Insert S a.
HW #4 (mostly by) Salim Sarımurat 04.12.2009 S. 1. 1. a. 1) Insert 6 2) Insert 8 3) Insert 30 4) Insert 40 2 5) Insert 50 6) Insert 61 7) Insert 70 1. b. 1) Insert 12 2) Insert 29 3) Insert 30 4) Insert
More informationOptimal Tree-decomposition Balancing and Reachability on Low Treewidth Graphs
Optimal Tree-decomposition Balancing and Reachability on Low Treewidth Graphs Krishnendu Chatterjee Rasmus Ibsen-Jensen Andreas Pavlogiannis IST Austria Abstract. We consider graphs with n nodes together
More informationCS60007 Algorithm Design and Analysis 2018 Assignment 1
CS60007 Algorithm Design and Analysis 2018 Assignment 1 Palash Dey and Swagato Sanyal Indian Institute of Technology, Kharagpur Please submit the solutions of the problems 6, 11, 12 and 13 (written in
More informationNon-context-Free Languages. CS215, Lecture 5 c
Non-context-Free Languages CS215, Lecture 5 c 2007 1 The Pumping Lemma Theorem. (Pumping Lemma) Let be context-free. There exists a positive integer divided into five pieces, Proof for for each, and..
More informationComputational Logic. Davide Martinenghi. Spring Free University of Bozen-Bolzano. Computational Logic Davide Martinenghi (1/30)
Computational Logic Davide Martinenghi Free University of Bozen-Bolzano Spring 2010 Computational Logic Davide Martinenghi (1/30) Propositional Logic - sequent calculus To overcome the problems of natural
More informationRandomized Algorithms III Min Cut
Chapter 11 Randomized Algorithms III Min Cut CS 57: Algorithms, Fall 01 October 1, 01 11.1 Min Cut 11.1.1 Problem Definition 11. Min cut 11..0.1 Min cut G = V, E): undirected graph, n vertices, m edges.
More informationBiased Quantiles. Flip Korn Graham Cormode S. Muthukrishnan
Biased Quantiles Graham Cormode cormode@bell-labs.com S. Muthukrishnan muthu@cs.rutgers.edu Flip Korn flip@research.att.com Divesh Srivastava divesh@research.att.com Quantiles Quantiles summarize data
More informationLecture 6 January 15, 2014
Advanced Graph Algorithms Jan-Apr 2014 Lecture 6 January 15, 2014 Lecturer: Saket Sourah Scrie: Prafullkumar P Tale 1 Overview In the last lecture we defined simple tree decomposition and stated that for
More informationHeaps and Priority Queues
Heaps and Priority Queues Motivation Situations where one has to choose the next most important from a collection. Examples: patients in an emergency room, scheduling programs in a multi-tasking OS. Need
More informationLecture 17: Trees and Merge Sort 10:00 AM, Oct 15, 2018
CS17 Integrated Introduction to Computer Science Klein Contents Lecture 17: Trees and Merge Sort 10:00 AM, Oct 15, 2018 1 Tree definitions 1 2 Analysis of mergesort using a binary tree 1 3 Analysis of
More informationInge Li Gørtz. Thank you to Kevin Wayne for inspiration to slides
02110 Inge Li Gørtz Thank you to Kevin Wayne for inspiration to slides Welcome Inge Li Gørtz. Reverse teaching and discussion of exercises: 3 teaching assistants 8.00-9.15 Group work 9.15-9.45 Discussions
More informationBinary Decision Diagrams
Binary Decision Diagrams Binary Decision Diagrams (BDDs) are a class of graphs that can be used as data structure for compactly representing boolean functions. BDDs were introduced by R. Bryant in 1986.
More informationReckhow s Theorem. Yuval Filmus. November 2010
Reckhow s Theorem Yuval Filmus November 2010 1 Introduction In 5.3.1 of his thesis [2], Reckhow showed that any two Frege systems p-simulate each other. One of the difficulties involves translation of
More informationarxiv: v1 [math.co] 22 Jan 2013
NESTED RECURSIONS, SIMULTANEOUS PARAMETERS AND TREE SUPERPOSITIONS ABRAHAM ISGUR, VITALY KUZNETSOV, MUSTAZEE RAHMAN, AND STEPHEN TANNY arxiv:1301.5055v1 [math.co] 22 Jan 2013 Abstract. We apply a tree-based
More information2-INF-237 Vybrané partie z dátových štruktúr 2-INF-237 Selected Topics in Data Structures
2-INF-237 Vybrané partie z dátových štruktúr 2-INF-237 Selected Topics in Data Structures Instructor: Broňa Brejová E-mail: brejova@fmph.uniba.sk Office: M163 Course webpage: http://compbio.fmph.uniba.sk/vyuka/vpds/
More informationFunctional Data Structures
Functional Data Structures with Isabelle/HOL Tobias Nipkow Fakultät für Informatik Technische Universität München 2017-2-3 1 Part II Functional Data Structures 2 Chapter 1 Binary Trees 3 1 Binary Trees
More informationCS 395T Computational Learning Theory. Scribe: Mike Halcrow. x 4. x 2. x 6
CS 395T Computational Learning Theory Lecture 3: September 0, 2007 Lecturer: Adam Klivans Scribe: Mike Halcrow 3. Decision List Recap In the last class, we determined that, when learning a t-decision list,
More information8: Splay Trees. Move-to-Front Heuristic. Splaying. Splay(12) CSE326 Spring April 16, Search for Pebbles: Move found item to front of list
: Splay Trees SE Spring 00 pril, 00 Move-to-Front Heuristic Search for ebbles: Fred Wilma ebbles ino Fred Wilma ino ebbles Move found item to front of list Frequently searched items will move to start
More informationData Structures 1 NTIN066
Data Structures 1 NTIN066 Jiří Fink https://kam.mff.cuni.cz/ fink/ Department of Theoretical Computer Science and Mathematical Logic Faculty of Mathematics and Physics Charles University in Prague Winter
More informationAlgorithm Analysis Recurrence Relation. Chung-Ang University, Jaesung Lee
Algorithm Analysis Recurrence Relation Chung-Ang University, Jaesung Lee Recursion 2 Recursion 3 Recursion in Real-world Fibonacci sequence = + Initial conditions: = 0 and = 1. = + = + = + 0, 1, 1, 2,
More informationRECOVERING NORMAL NETWORKS FROM SHORTEST INTER-TAXA DISTANCE INFORMATION
RECOVERING NORMAL NETWORKS FROM SHORTEST INTER-TAXA DISTANCE INFORMATION MAGNUS BORDEWICH, KATHARINA T. HUBER, VINCENT MOULTON, AND CHARLES SEMPLE Abstract. Phylogenetic networks are a type of leaf-labelled,
More informationEvolving a New Feature for a Working Program
Evolving a New Feature for a Working Program Mike Stimpson arxiv:1104.0283v1 [cs.ne] 2 Apr 2011 January 18, 2013 Abstract A genetic programming system is created. A first fitness function f 1 is used to
More informationENS Lyon Camp. Day 2. Basic group. Cartesian Tree. 26 October
ENS Lyon Camp. Day 2. Basic group. Cartesian Tree. 26 October Contents 1 Cartesian Tree. Definition. 1 2 Cartesian Tree. Construction 1 3 Cartesian Tree. Operations. 2 3.1 Split............................................
More information6.1 The Pumping Lemma for CFLs 6.2 Intersections and Complements of CFLs
CSC4510/6510 AUTOMATA 6.1 The Pumping Lemma for CFLs 6.2 Intersections and Complements of CFLs The Pumping Lemma for Context Free Languages One way to prove AnBn is not regular is to use the pumping lemma
More informationBayesian Networks: Independencies and Inference
Bayesian Networks: Independencies and Inference Scott Davies and Andrew Moore Note to other teachers and users of these slides. Andrew and Scott would be delighted if you found this source material useful
More information9 Union Find. 9 Union Find. List Implementation. 9 Union Find. Union Find Data Structure P: Maintains a partition of disjoint sets over elements.
Union Find Data Structure P: Maintains a partition of disjoint sets over elements. P. makeset(x): Given an element x, adds x to the data-structure and creates a singleton set that contains only this element.
More informationChapter 1. The Postulates of the Special Theory of Relativity
Chapter 1 The Postulates of the Special Theory of Relatiity Imagine a railroad station with six tracks (Fig. 1.1): On track 1a a train has stopped, the train on track 1b is going to the east at a elocity
More information