16. Binary Search Trees

Size: px
Start display at page:

Download "16. Binary Search Trees"

Transcription

1 Dictionary imlementation 16. Binary Search Trees [Ottman/Widmayer, Ka..1, Cormen et al, Ka ] Hashing: imlementation of dictionaries with exected very fast access times. Disadvantages of hashing: linear access time in worst case. Some oerations not suorted at all: enumerate keys in increasing order next smallest key to given key 1 1 Trees Trees Trees are Generalized lists: nodes can have more than one successor Secial grahs: grahs consist of nodes and edges. A tree is a fully connected, directed, acyclic grah. Use Decision trees: hierarchic reresentation of decision rules syntax trees: arsing and traversing of exressions, e.g. in a comiler Code tress: reresentation of a code, e.g. morse alhabet, huffman code Search trees: allow efficient searching for an element by value 0 1

2 Examles Examles short start long / E T I A N M S U R W D K G O / 7.0 H V F U L A P I B X C Y Z Q Ö CH Morsealhabet Exression tree Nomenclature Binary Trees Wurzel A binary tree is either I inner node W E arent a leaf, i.e. an emty tree, or an inner leaf with two trees T l (left subtree) and T r (right subtree) as left and right successor. leaves K child Order of the tree: maximum number of child nodes, here: Height of the tree: maximum ath length root leaf (here: ) In each node v we store a key v.key and two nodes v.left and v.right to the roots of the left and right subtree. a leaf is reresented by the null-ointer left key right

3 Binary search tree A binary search tree is a binary tree that fulfils the search tree roerty: Every node v stores a key Keys in the left subtree v.left of v are smaller than v.key Key in the right subtree v.right of v are larger than v.key Searching Inut : Binary search tree with root r, key k Outut : Node v with v.key = k or null v r while v null do if k = v.key then return v else if k < v.key then v v.left else v v.right return null 1 Search (1) null Height of a tree Insertion of a key The height h(t ) of a tree T with root r is given by { 0 if r = null h(r) = 1 + max{h(r.left), h(r.right)} otherwise. The worst case run time of the search is thus O(h(T )) Insertion of the key k Search for k If successful search: outut error Of no success: insert the key at the leaf reached Insert () 1

4 Remove node Remove node Three cases ossible: Node has no children Node has one child Node has two children [Leaves do not count here] 1 Node has no children Simle case: relace node by leaf. 1 remove() Remove node Remove node Node has one child Also simle: relace node by single child. 1 remove() 1 Node has two children The following observation hels: the smallest key in the right subtree v.right (the symmetric successor of v) is smaller than all keys in v.right is greater than all keys in v.left and cannot have a left child. Solution: relace v by its symmetric successor. 1

5 By symmetry... Algorithm SymmetricSuccessor(v) Node has two children Also ossible: relace v by its symmetric redecessor. 1 Inut : Node v of a binary search tree. Outut : Symmetric successor of v w v.right x w.left while x null do w x x x.left return w Analysis Traversal ossibilities Deletion of an element v from a tree T requires O(h(T )) fundamental stes: Finding v has costs O(h(T )) If v has maximal one child unequal to nullthen removal takes O(1) stes Finding the symmetric successor n of v takes O(h(T )) stes. Removal and insertion of n takes O(1) stes. reorder: v, then T left (v), then T right (v).,,,,,,, 1 ostorder: T left (v), then T right (v), then v.,,,,, 1,, inorder: T left (v), then v, then T right (v).,,,,,,,

6 Further suorted oerations Degenerated search trees Min(T ): Read-out minimal value in O(h) ExtractMin(T ): Read-out and remove minimal value in O(h) List(T ): Outut the sorted list of elements Join(T 1, T ): Merge two trees with max(t 1 ) < min(t ) in O(n). 1 1 Insert,,,,,,1 ideally balanced 1 Insert,,,,,,1 linear list 1 Insert 1,,,,,, linear list Objective 17. AVL Trees Balanced Trees [Ottman/Widmayer, Ka..-..1, Cormen et al, Ka. Problem -] Searching, insertion and removal of a key in a tree generated from n keys inserted in random order takes exected number of stes O(log n). But worst case Θ(n) (degenerated tree). Goal: avoidance of degeneration. Artificial balancing of the tree for each udate-oeration of a tree. Balancing: guarantee that a tree with n nodes always has a height of O(log n). Adelson-Venskii and Landis (16): AVL-Trees 0 1

7 Balance of a node AVL Condition The height balance of a node v is defined as the height difference of its sub-trees T l (v) and T r (v) bal(v) := h(t r (v)) h(t l (v)) h l bal(v) T l (v) v T r (v) h r AVL Condition: for eacn node v of a tree bal(v) { 1, 0, 1} v h h + 1 T l (v) T r (v) h + (Counter-)Examles Number of Leaves AVL tree with height AVL tree with height No AVL tree 1. observation: a binary search tree with n keys rovides exactly n + 1 leaves. Simle induction argument.. observation: a lower bound of the number of leaves in a search tree with given height imlies an uer bound of the height of a search tree with given number of keys.

8 Lower bound of the leaves Lower bound of the leaves for h > Height of one subtree h 1. Height of the other subtree h. v h h 1 h Minimal number of leaves M(h) is AVL tree with height 1 has M(1) := leaves. M(h) = M(h 1) + M(h ) T l (v) T r (v) AVL tree with height has at least M() := leaves. Overal we have M(h) = F h+ with Fibonacci-numbers F 0 := 0, F 1 := 1, F n := F n 1 + F n for n > [Fibonacci Numbers: closed form] [Fibonacci Numbers: closed form] Closed form of the Fibonacci numbers: comutation via generation functions: 1 Power series aroach f(x) := F i x i For Fibonacci Numbers it holds that F 0 = 0, F 1 = 1, F i = F i 1 + F i i > 1. Therefore: f(x) = x + F i x i = x + F i 1 x i + F i x i = x + x = x + x i= i= F i 1 x i 1 + x i= F i x i + x = x + x f(x) + x f(x). i= F i x i i= F i x i

9 [Fibonacci Numbers: closed form] [Fibonacci Numbers: closed form] Thus: with the roots φ and ˆφ of 1 x x. f(x) (1 x x ) = x. x f(x) = 1 x x x f(x) = (1 φx) (1 ˆφx) φ = 1 + ˆφ = 1. 0 It holds that: Damit: (1 ˆφx) (1 φx) = x. f(x) = 1 (1 ˆφx) (1 φx) (1 φx) (1 ˆφx) = 1 ( 1 1 φx 1 ) 1 ˆφx 1 [Fibonacci Numbers: closed form] Power series of g a (x) = 1 1 a x (a R): 1 1 a x = a i x i. E.g. Taylor series of g a (x) at x = 0 or like this: Let G i x i a ower series of g. By the identity g a (x)(1 a x) = 1 it holds that 1 = G i x i a G i x i+1 = G 0 + (G i a G i 1 ) x i Thus G 0 = 1 and G i = a G i 1 G i = a i. i=1 [Fibonacci Numbers: closed form] 6 Fill in the ower series: f(x) = 1 ( 1 1 φx 1 ) ( 1 ˆφx = 1 φ i x i 1 = (φ i ˆφ i )x i ) ˆφ i x i Comarison of the coefficients with f(x) = F i x i yields F i = 1 (φ i ˆφ i ).

10 Fibonacci Numbers It holds that F i = 1 (φ i ˆφ i ) with roots φ, ˆφ of the equation x = x + 1 (golden ratio), thus φ = 1+, ˆφ = 1. Proof (induction). Immediate for i = 0, i = 1. Let i > : F i = F i 1 + F i = 1 (φ i 1 ˆφ i 1 ) + 1 (φ i ˆφ i ) = 1 (φ i 1 + φ i ) 1 ( ˆφ i 1 + ˆφ i ) = 1 φ i (φ + 1) 1 ˆφi ( ˆφ + 1) = 1 φ i (φ ) 1 ˆφi ( ˆφ ) = 1 (φ i ˆφ i ). Tree Height Because ˆφ < 1, overal we have ( M(h) Θ 1 + ) h Ω(1.61 h ) and thus h 1. log n + c. AVL tree is asymtotically not more than % higher than a erfectly balanced tree. Insertion Balance at Insertion Point Balance Kee the balance stored in each node Re-balance the tree in each udate-oeration New node n is inserted: Insert the node as for a search tree. Check the balance condition increasing from n to the root. n case 1: bal() = +1 case : bal() = 1 Finished in both cases because the subtree height did not change n 6 7

11 Balance at Insertion Point uin() - invariant case.1: bal() = 0 right n case.: bal() = 0, left n When uin() is called it holds that the subtree from is grown and bal() { 1, +1} Not finished in both case. Call of uin() uin() Assumtion: is left son of case 1: bal() = +1, done. 0 1 case : bal() = 0, uin() uin() Assumtion: is left son of 1 case : bal() = 1, In both cases the AVL-Condition holds for the subtree from This case is roblematic: adding n to the subtree from has violated the AVL-condition. Re-balance! 17 If is a right son: symmetric cases with exchange of +1 and 1 Two cases bal() = 1, bal() =

12 Rotationen Rotationen case 1.1 bal() = 1. 1 case 1.1 bal() = 1. 1 y 1 x 0 z 1 y 0 x 1 t h 1 t t 1 h 1 h rotation right t 1 t t h h 1 h 1 y 0 x +1 t 1 t h 1 t h h 1 h y h h 1 t h 1 double rotation left-right x t t 1 t t h h 1 h 1 h 1 h 1 h z 1 right son: bal() = bal() = +1, left rotation 1 right son: bal() = +1, bal() = 1, double rotation right left 6 6 Analysis Tree height: O(log n). Insertion like in binary search tree. Balancing via recursion from node to the root. Maximal ath lenght O(log n). Insertion in an AVL-tree rovides run time costs of O(log n). Deletion Case 1: Children of node n are both leaves Let be arent node of n. Other subtree has height h = 0, 1 or. h = 1: Adat bal(). h = 0: Adat bal(). Call uout(). h = : Rebalanciere des Teilbaumes. Call uout(). n h = 0, 1, h = 0, 1, 6 6

13 Deletion Deletion Case : one child k of node n is an inner node Relace n by k. uout(k) Case : both children of node n are inner nodes Relace n by symmetric successor. uout(k) n k Deletion of the symmetric successor is as in case 1 or. k uout() uout() Case (a).: bal() = +1. Let q be brother of (a)..1: bal(q) = 0. 0 Let be the arent node of. (a) left child of y +1 z 1 1 bal() = 1 bal() 0. uout() bal() = 0 bal() +1. bal() = +1 next slides. (b) right child of : Symmetric cases exchanging +1 and 1. x 0 q z 0 1 h 1 h 1 Left Rotate(y) x 0 1 y +1 h + 1 h + 1 h 1 h 1 h + 1 h (b)..1: bal() = 1, bal(q) = 1, Right rotation 6

14 uout() uout() Case (a).: bal() = +1. (a)..: bal(q) = Case (a).: bal() = +1. (a)..: bal(q) = 1. y +1 r z 0 y +1 r w 0 x 0 q z +1 1 h 1 h 1 h h + 1 Left Rotate(y) y 0 x 0 1 h 1 h 1 h h + 1 lus uout(r). x 0 q z 1 h 1 h 1 w 1 h Rotate right (z) left (y) x y h 1 h 1 h lus uout(r). z 1 (b)..: bal() = 1, bal(q) = +1, Right rotation+uout 70 (b)..: bal() = 1, bal(q) = 1, left-right rotation + uout 71 Conclusion AVL trees have worst-case asymtotic runtimes of O(log n) for searching, insertion and deletion of keys. Insertion and deletion is relatively involved and an overkill for really small roblems. 7

16. Binary Search Trees

16. 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 information

16. Binary Search Trees. [Ottman/Widmayer, Kap. 5.1, Cormen et al, Kap ]

16. 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 information

16. Binary Search Trees. [Ottman/Widmayer, Kap. 5.1, Cormen et al, Kap ]

16. 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 information

Ordered Dictionary & Binary Search Tree

Ordered 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 information

Weight-balanced Binary Search Trees

Weight-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 information

An Introduction To Range Searching

An Introduction To Range Searching An Introduction To Range Searching Jan Vahrenhold eartment of Comuter Science Westfälische Wilhelms-Universität Münster, Germany. Overview 1. Introduction: Problem Statement, Lower Bounds 2. Range Searching

More information

Weight-balanced Binary Search Trees

Weight-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 information

Topic: Lower Bounds on Randomized Algorithms Date: September 22, 2004 Scribe: Srinath Sridhar

Topic: Lower Bounds on Randomized Algorithms Date: September 22, 2004 Scribe: Srinath Sridhar 15-859(M): Randomized Algorithms Lecturer: Anuam Guta Toic: Lower Bounds on Randomized Algorithms Date: Setember 22, 2004 Scribe: Srinath Sridhar 4.1 Introduction In this lecture, we will first consider

More information

Data Structures and Algorithms " Search Trees!!

Data 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 information

25. Minimum Spanning Trees

25. 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 information

25. Minimum Spanning Trees

25. 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 information

Dictionary: an abstract data type

Dictionary: 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 information

Fundamental Algorithms

Fundamental Algorithms Fundamental Algithms Chapter 4: AVL Trees Jan Křetínský Winter 2016/17 Chapter 4: AVL Trees, Winter 2016/17 1 Part I AVL Trees (Adelson-Velsky and Landis, 1962) Chapter 4: AVL Trees, Winter 2016/17 2 Binary

More information

Dictionary: an abstract data type

Dictionary: 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 information

Approximating min-max k-clustering

Approximating min-max k-clustering Aroximating min-max k-clustering Asaf Levin July 24, 2007 Abstract We consider the roblems of set artitioning into k clusters with minimum total cost and minimum of the maximum cost of a cluster. The cost

More information

Model checking, verification of CTL. One must verify or expel... doubts, and convert them into the certainty of YES [Thomas Carlyle]

Model checking, verification of CTL. One must verify or expel... doubts, and convert them into the certainty of YES [Thomas Carlyle] Chater 5 Model checking, verification of CTL One must verify or exel... doubts, and convert them into the certainty of YES or NO. [Thomas Carlyle] 5. The verification setting Page 66 We introduce linear

More information

Search Trees. Chapter 10. CSE 2011 Prof. J. Elder Last Updated: :52 AM

Search 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 information

Binary Search Trees. Dictionary Operations: Additional operations: find(key) insert(key, value) erase(key)

Binary 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 information

4.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 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 information

Chapter 5 Data Structures Algorithm Theory WS 2017/18 Fabian Kuhn

Chapter 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 information

The Graph Accessibility Problem and the Universality of the Collision CRCW Conflict Resolution Rule

The Graph Accessibility Problem and the Universality of the Collision CRCW Conflict Resolution Rule The Grah Accessibility Problem and the Universality of the Collision CRCW Conflict Resolution Rule STEFAN D. BRUDA Deartment of Comuter Science Bisho s University Lennoxville, Quebec J1M 1Z7 CANADA bruda@cs.ubishos.ca

More information

Problem. Problem Given a dictionary and a word. Which page (if any) contains the given word? 3 / 26

Problem. 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 information

Functional Data Structures

Functional 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 information

AVL Trees. Manolis Koubarakis. Data Structures and Programming Techniques

AVL 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 information

The null-pointers in a binary search tree are replaced by pointers to special null-vertices, that do not carry any object-data

The 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 information

Assignment 5: Solutions

Assignment 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 information

GIVEN an input sequence x 0,..., x n 1 and the

GIVEN an input sequence x 0,..., x n 1 and the 1 Running Max/Min Filters using 1 + o(1) Comarisons er Samle Hao Yuan, Member, IEEE, and Mikhail J. Atallah, Fellow, IEEE Abstract A running max (or min) filter asks for the maximum or (minimum) elements

More information

Quiz 1 Solutions. Problem 2. Asymptotics & Recurrences [20 points] (3 parts)

Quiz 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 information

Proof Nets and Boolean Circuits

Proof Nets and Boolean Circuits Proof Nets and Boolean Circuits Kazushige Terui terui@nii.ac.j National Institute of Informatics, Tokyo 14/07/04, Turku.1/44 Motivation (1) Proofs-as-Programs (Curry-Howard) corresondence: Proofs = Programs

More information

21. Dynamic Programming III. FPTAS [Ottman/Widmayer, Kap. 7.2, 7.3, Cormen et al, Kap. 15,35.5]

21. Dynamic Programming III. FPTAS [Ottman/Widmayer, Kap. 7.2, 7.3, Cormen et al, Kap. 15,35.5] 575 21. Dynamic Programming III FPTAS [Ottman/Widmayer, Kap. 7.2, 7.3, Cormen et al, Kap. 15,35.5] Approximation 576 Let ε (0, 1) given. Let I opt an optimal selection. No try to find a valid selection

More information

CS 240 Data Structures and Data Management. Module 4: Dictionaries

CS 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 information

Fundamental Algorithms

Fundamental 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 information

Splay Trees. Splay Trees. Splay Trees. Splay Trees

Splay Trees. Splay Trees. Splay Trees. Splay Trees Slay Trees Slay Trees isadvantae of balanced search trees: worst case; no advantae for easy inuts additional memory required comlicated imlementation Slay Trees: + after access, an element is moved to

More information

INF2220: algorithms and data structures Series 1

INF2220: 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 information

John Weatherwax. Analysis of Parallel Depth First Search Algorithms

John Weatherwax. Analysis of Parallel Depth First Search Algorithms Sulementary Discussions and Solutions to Selected Problems in: Introduction to Parallel Comuting by Viin Kumar, Ananth Grama, Anshul Guta, & George Karyis John Weatherwax Chater 8 Analysis of Parallel

More information

Amortized analysis. Amortized analysis

Amortized analysis. Amortized analysis In amortized analysis the goal is to bound the worst case time of a sequence of operations on a data-structure. If n operations take T (n) time (worst case), the amortized cost of an operation is T (n)/n.

More information

Outline. CS21 Decidability and Tractability. Regular expressions and FA. Regular expressions and FA. Regular expressions and FA

Outline. CS21 Decidability and Tractability. Regular expressions and FA. Regular expressions and FA. Regular expressions and FA Outline CS21 Decidability and Tractability Lecture 4 January 14, 2019 FA and Regular Exressions Non-regular languages: Puming Lemma Pushdown Automata Context-Free Grammars and Languages January 14, 2019

More information

CS Data Structures and Algorithm Analysis

CS 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 information

ECE 534 Information Theory - Midterm 2

ECE 534 Information Theory - Midterm 2 ECE 534 Information Theory - Midterm Nov.4, 009. 3:30-4:45 in LH03. You will be given the full class time: 75 minutes. Use it wisely! Many of the roblems have short answers; try to find shortcuts. You

More information

Advanced Implementations of Tables: Balanced Search Trees and Hashing

Advanced 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 information

8 Priority Queues. 8 Priority Queues. Prim s Minimum Spanning Tree Algorithm. Dijkstra s Shortest Path Algorithm

8 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 information

MATH 2710: NOTES FOR ANALYSIS

MATH 2710: NOTES FOR ANALYSIS MATH 270: NOTES FOR ANALYSIS The main ideas we will learn from analysis center around the idea of a limit. Limits occurs in several settings. We will start with finite limits of sequences, then cover infinite

More information

Sorting Algorithms. We have already seen: Selection-sort Insertion-sort Heap-sort. We will see: Bubble-sort Merge-sort Quick-sort

Sorting Algorithms. We have already seen: Selection-sort Insertion-sort Heap-sort. We will see: Bubble-sort Merge-sort Quick-sort Sorting Algorithms We have already seen: Selection-sort Insertion-sort Heap-sort We will see: Bubble-sort Merge-sort Quick-sort We will show that: O(n log n) is optimal for comparison based sorting. Bubble-Sort

More information

Lecture 6. 2 Recurrence/transience, harmonic functions and martingales

Lecture 6. 2 Recurrence/transience, harmonic functions and martingales Lecture 6 Classification of states We have shown that all states of an irreducible countable state Markov chain must of the same tye. This gives rise to the following classification. Definition. [Classification

More information

Feedback-error control

Feedback-error control Chater 4 Feedback-error control 4.1 Introduction This chater exlains the feedback-error (FBE) control scheme originally described by Kawato [, 87, 8]. FBE is a widely used neural network based controller

More information

HENSEL S LEMMA KEITH CONRAD

HENSEL S LEMMA KEITH CONRAD HENSEL S LEMMA KEITH CONRAD 1. Introduction In the -adic integers, congruences are aroximations: for a and b in Z, a b mod n is the same as a b 1/ n. Turning information modulo one ower of into similar

More information

A randomized sorting algorithm on the BSP model

A randomized sorting algorithm on the BSP model A randomized sorting algorithm on the BSP model Alexandros V. Gerbessiotis a, Constantinos J. Siniolakis b a CS Deartment, New Jersey Institute of Technology, Newark, NJ 07102, USA b The American College

More information

where x i is the ith coordinate of x R N. 1. Show that the following upper bound holds for the growth function of H:

where x i is the ith coordinate of x R N. 1. Show that the following upper bound holds for the growth function of H: Mehryar Mohri Foundations of Machine Learning Courant Institute of Mathematical Sciences Homework assignment 2 October 25, 2017 Due: November 08, 2017 A. Growth function Growth function of stum functions.

More information

Search Trees. EECS 2011 Prof. J. Elder Last Updated: 24 March 2015

Search 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 information

Each 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 =.

Each 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 information

UPPAAL tutorial What s inside UPPAAL The UPPAAL input languages

UPPAAL tutorial What s inside UPPAAL The UPPAAL input languages UPPAAL tutorial What s inside UPPAAL The UPPAAL inut languages 1 UPPAAL tool Develoed jointly by Usala & Aalborg University >>8,000 downloads since 1999 1 UPPAAL Tool Simulation Modeling Verification 3

More information

1. Problem I calculated these out by hand. It was tedious, but kind of fun, in a a computer should really be doing this sort of way.

1. Problem I calculated these out by hand. It was tedious, but kind of fun, in a a computer should really be doing this sort of way. . Problem 5.2-. I calculated these out by hand. It was tedious, but kind of fun, in a a computer should really be doing this sort of way. 2 655 95 45 243 77 33 33 93 86 5 36 8 3 5 2 4 2 2 2 4 2 2 4 4 2

More information

Information collection on a graph

Information collection on a graph Information collection on a grah Ilya O. Ryzhov Warren Powell February 10, 2010 Abstract We derive a knowledge gradient olicy for an otimal learning roblem on a grah, in which we use sequential measurements

More information

Round-off Errors and Computer Arithmetic - (1.2)

Round-off Errors and Computer Arithmetic - (1.2) Round-off Errors and Comuter Arithmetic - (.). Round-off Errors: Round-off errors is roduced when a calculator or comuter is used to erform real number calculations. That is because the arithmetic erformed

More information

Data Structures and and Algorithm Xiaoqing Zheng

Data 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 information

Graphs and Trees Binary Search Trees AVL-Trees (a,b)-trees Splay-Trees. Search Trees. Tobias Lieber. April 14, 2008

Graphs 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 information

Analysis of Algorithms. Outline 1 Introduction Basic Definitions Ordered Trees. Fibonacci Heaps. Andres Mendez-Vazquez. October 29, Notes.

Analysis 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 information

Analysis of execution time for parallel algorithm to dertmine if it is worth the effort to code and debug in parallel

Analysis of execution time for parallel algorithm to dertmine if it is worth the effort to code and debug in parallel Performance Analysis Introduction Analysis of execution time for arallel algorithm to dertmine if it is worth the effort to code and debug in arallel Understanding barriers to high erformance and redict

More information

Decoding Linear Block Codes Using a Priority-First Search: Performance Analysis and Suboptimal Version

Decoding Linear Block Codes Using a Priority-First Search: Performance Analysis and Suboptimal Version IEEE TRANSACTIONS ON INFORMATION THEORY, VOL. 44, NO. 3, MAY 1998 133 Decoding Linear Block Codes Using a Priority-First Search Performance Analysis Subotimal Version Yunghsiang S. Han, Member, IEEE, Carlos

More information

Binary Search Trees. Motivation

Binary 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 information

4. Score normalization technical details We now discuss the technical details of the score normalization method.

4. Score normalization technical details We now discuss the technical details of the score normalization method. SMT SCORING SYSTEM This document describes the scoring system for the Stanford Math Tournament We begin by giving an overview of the changes to scoring and a non-technical descrition of the scoring rules

More information

A Parallel Algorithm for Minimization of Finite Automata

A Parallel Algorithm for Minimization of Finite Automata A Parallel Algorithm for Minimization of Finite Automata B. Ravikumar X. Xiong Deartment of Comuter Science University of Rhode Island Kingston, RI 02881 E-mail: fravi,xiongg@cs.uri.edu Abstract In this

More information

Binary Decision Diagrams. Graphs. Boolean Functions

Binary 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 information

Information collection on a graph

Information collection on a graph Information collection on a grah Ilya O. Ryzhov Warren Powell October 25, 2009 Abstract We derive a knowledge gradient olicy for an otimal learning roblem on a grah, in which we use sequential measurements

More information

RANDOM WALKS AND PERCOLATION: AN ANALYSIS OF CURRENT RESEARCH ON MODELING NATURAL PROCESSES

RANDOM WALKS AND PERCOLATION: AN ANALYSIS OF CURRENT RESEARCH ON MODELING NATURAL PROCESSES RANDOM WALKS AND PERCOLATION: AN ANALYSIS OF CURRENT RESEARCH ON MODELING NATURAL PROCESSES AARON ZWIEBACH Abstract. In this aer we will analyze research that has been recently done in the field of discrete

More information

CS361 Homework #3 Solutions

CS361 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 information

Fibonacci (Min-)Heap. (I draw dashed lines in place of of circular lists.) 1 / 17

Fibonacci (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 information

Alpha-Beta Pruning: Algorithm and Analysis

Alpha-Beta Pruning: Algorithm and Analysis Alpha-Beta Pruning: Algorithm and Analysis Tsan-sheng Hsu tshsu@iis.sinica.edu.tw http://www.iis.sinica.edu.tw/~tshsu 1 Introduction Alpha-beta pruning is the standard searching procedure used for 2-person

More information

Finding Shortest Hamiltonian Path is in P. Abstract

Finding Shortest Hamiltonian Path is in P. Abstract Finding Shortest Hamiltonian Path is in P Dhananay P. Mehendale Sir Parashurambhau College, Tilak Road, Pune, India bstract The roblem of finding shortest Hamiltonian ath in a eighted comlete grah belongs

More information

CS 151. Red Black Trees & Structural Induction. Thursday, November 1, 12

CS 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 information

XReason: A Semantic Approach that Reasons with Patterns to Answer XML Keyword Queries

XReason: A Semantic Approach that Reasons with Patterns to Answer XML Keyword Queries XReason: A Semantic Aroach that Reasons with Patterns to Answer XML Keyword Queries Cem Aksoy 1, Aggeliki Dimitriou 2, Dimitri Theodoratos 1, Xiaoying Wu 3 1 New Jersey Institute of Technology, Newark,

More information

Game Specification in the Trias Politica

Game Specification in the Trias Politica Game Secification in the Trias Politica Guido Boella a Leendert van der Torre b a Diartimento di Informatica - Università di Torino - Italy b CWI - Amsterdam - The Netherlands Abstract In this aer we formalize

More information

Parallelism and Locality in Priority Queues. A. Ranade S. Cheng E. Deprit J. Jones S. Shih. University of California. Berkeley, CA 94720

Parallelism and Locality in Priority Queues. A. Ranade S. Cheng E. Deprit J. Jones S. Shih. University of California. Berkeley, CA 94720 Parallelism and Locality in Priority Queues A. Ranade S. Cheng E. Derit J. Jones S. Shih Comuter Science Division University of California Berkeley, CA 94720 Abstract We exlore two ways of incororating

More information

7.3 AVL-Trees. Definition 15. Lemma 16. AVL-trees are binary search trees that fulfill the following balance condition.

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 information

A Social Welfare Optimal Sequential Allocation Procedure

A Social Welfare Optimal Sequential Allocation Procedure A Social Welfare Otimal Sequential Allocation Procedure Thomas Kalinowsi Universität Rostoc, Germany Nina Narodytsa and Toby Walsh NICTA and UNSW, Australia May 2, 201 Abstract We consider a simle sequential

More information

Theoretically Optimal and Empirically Efficient R-trees with Strong Parallelizability

Theoretically Optimal and Empirically Efficient R-trees with Strong Parallelizability Theoretically Otimal and Emirically Efficient R-trees with Strong Parallelizability Jianzhong Qi, Yufei Tao, Yanchuan Chang, Rui Zhang School of Comuting and Information Systems, The University of Melbourne

More information

Convex Optimization methods for Computing Channel Capacity

Convex Optimization methods for Computing Channel Capacity Convex Otimization methods for Comuting Channel Caacity Abhishek Sinha Laboratory for Information and Decision Systems (LIDS), MIT sinhaa@mit.edu May 15, 2014 We consider a classical comutational roblem

More information

Robustness of classifiers to uniform l p and Gaussian noise Supplementary material

Robustness of classifiers to uniform l p and Gaussian noise Supplementary material Robustness of classifiers to uniform l and Gaussian noise Sulementary material Jean-Yves Franceschi Ecole Normale Suérieure de Lyon LIP UMR 5668 Omar Fawzi Ecole Normale Suérieure de Lyon LIP UMR 5668

More information

ENS Lyon Camp. Day 2. Basic group. Cartesian Tree. 26 October

ENS 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 information

q-ary Symmetric Channel for Large q

q-ary Symmetric Channel for Large q List-Message Passing Achieves Caacity on the q-ary Symmetric Channel for Large q Fan Zhang and Henry D Pfister Deartment of Electrical and Comuter Engineering, Texas A&M University {fanzhang,hfister}@tamuedu

More information

Universal Finite Memory Coding of Binary Sequences

Universal Finite Memory Coding of Binary Sequences Deartment of Electrical Engineering Systems Universal Finite Memory Coding of Binary Sequences Thesis submitted towards the degree of Master of Science in Electrical and Electronic Engineering in Tel-Aviv

More information

Finite-State Verification or Model Checking. Finite State Verification (FSV) or Model Checking

Finite-State Verification or Model Checking. Finite State Verification (FSV) or Model Checking Finite-State Verification or Model Checking Finite State Verification (FSV) or Model Checking Holds the romise of roviding a cost effective way of verifying imortant roerties about a system Not all faults

More information

On Line Parameter Estimation of Electric Systems using the Bacterial Foraging Algorithm

On Line Parameter Estimation of Electric Systems using the Bacterial Foraging Algorithm On Line Parameter Estimation of Electric Systems using the Bacterial Foraging Algorithm Gabriel Noriega, José Restreo, Víctor Guzmán, Maribel Giménez and José Aller Universidad Simón Bolívar Valle de Sartenejas,

More information

Alpha-Beta Pruning: Algorithm and Analysis

Alpha-Beta Pruning: Algorithm and Analysis Alpha-Beta Pruning: Algorithm and Analysis Tsan-sheng Hsu tshsu@iis.sinica.edu.tw http://www.iis.sinica.edu.tw/~tshsu 1 Introduction Alpha-beta pruning is the standard searching procedure used for 2-person

More information

Lilian Markenzon 1, Nair Maria Maia de Abreu 2* and Luciana Lee 3

Lilian Markenzon 1, Nair Maria Maia de Abreu 2* and Luciana Lee 3 Pesquisa Oeracional (2013) 33(1): 123-132 2013 Brazilian Oerations Research Society Printed version ISSN 0101-7438 / Online version ISSN 1678-5142 www.scielo.br/oe SOME RESULTS ABOUT THE CONNECTIVITY OF

More information

Alpha-Beta Pruning: Algorithm and Analysis

Alpha-Beta Pruning: Algorithm and Analysis Alpha-Beta Pruning: Algorithm and Analysis Tsan-sheng Hsu tshsu@iis.sinica.edu.tw http://www.iis.sinica.edu.tw/~tshsu 1 Introduction Alpha-beta pruning is the standard searching procedure used for solving

More information

Outline. EECS150 - Digital Design Lecture 26 Error Correction Codes, Linear Feedback Shift Registers (LFSRs) Simple Error Detection Coding

Outline. EECS150 - Digital Design Lecture 26 Error Correction Codes, Linear Feedback Shift Registers (LFSRs) Simple Error Detection Coding Outline EECS150 - Digital Design Lecture 26 Error Correction Codes, Linear Feedback Shift Registers (LFSRs) Error detection using arity Hamming code for error detection/correction Linear Feedback Shift

More information

searching algorithms

searching 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 information

PHYS 301 HOMEWORK #9-- SOLUTIONS

PHYS 301 HOMEWORK #9-- SOLUTIONS PHYS 0 HOMEWORK #9-- SOLUTIONS. We are asked to use Dirichlet' s theorem to determine the value of f (x) as defined below at x = 0, ± /, ± f(x) = 0, - < x

More information

Binary Search Trees. Lecture 29 Section Robb T. Koether. Hampden-Sydney College. Fri, Apr 8, 2016

Binary 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 information

PROFIT MAXIMIZATION. π = p y Σ n i=1 w i x i (2)

PROFIT MAXIMIZATION. π = p y Σ n i=1 w i x i (2) PROFIT MAXIMIZATION DEFINITION OF A NEOCLASSICAL FIRM A neoclassical firm is an organization that controls the transformation of inuts (resources it owns or urchases into oututs or roducts (valued roducts

More information

Introduction to Probability and Statistics

Introduction to Probability and Statistics Introduction to Probability and Statistics Chater 8 Ammar M. Sarhan, asarhan@mathstat.dal.ca Deartment of Mathematics and Statistics, Dalhousie University Fall Semester 28 Chater 8 Tests of Hyotheses Based

More information

Premaster Course Algorithms 1 Chapter 3: Elementary Data Structures

Premaster Course Algorithms 1 Chapter 3: Elementary Data Structures Premaster Course Algorithms 1 Chapter 3: Elementary Data Structures Christian Scheideler SS 2018 23.04.2018 Chapter 3 1 Overview Basic data structures Search structures (successor searching) Dictionaries

More information

Introduction to Group Theory Note 1

Introduction to Group Theory Note 1 Introduction to Grou Theory Note July 7, 009 Contents INTRODUCTION. Examles OF Symmetry Grous in Physics................................. ELEMENT OF GROUP THEORY. De nition of Grou................................................

More information

On the capacity of the general trapdoor channel with feedback

On the capacity of the general trapdoor channel with feedback On the caacity of the general tradoor channel with feedback Jui Wu and Achilleas Anastasooulos Electrical Engineering and Comuter Science Deartment University of Michigan Ann Arbor, MI, 48109-1 email:

More information

An introduction to forest-regular languages

An introduction to forest-regular languages An introduction to forest-regular languages Mika Raento Basic Research Unit, Helsinki Institute for Information Technology Deartment of Comuter Science, University of Helsinki Mika.Raento@cs.Helsinki.FI

More information

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

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 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 information

Binary Decision Diagrams

Binary 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 information

Distributed Rule-Based Inference in the Presence of Redundant Information

Distributed Rule-Based Inference in the Presence of Redundant Information istribution Statement : roved for ublic release; distribution is unlimited. istributed Rule-ased Inference in the Presence of Redundant Information June 8, 004 William J. Farrell III Lockheed Martin dvanced

More information

1-way quantum finite automata: strengths, weaknesses and generalizations

1-way quantum finite automata: strengths, weaknesses and generalizations 1-way quantum finite automata: strengths, weaknesses and generalizations arxiv:quant-h/9802062v3 30 Se 1998 Andris Ambainis UC Berkeley Abstract Rūsiņš Freivalds University of Latvia We study 1-way quantum

More information