Algorithms and Data Structures

Similar documents
Algorithms. AVL Tree

Algorithms and Data Structures

Algorithms and Data Structures

AVL Trees. (AVL Trees) Data Structures and Programming Spring / 17

Part 2: Balanced Trees

Fundamental Algorithms

Algorithms and Data S tructures Structures Optimal S earc Sear h ch Tr T ees; r T ries Tries Ulf Leser

Self-Balancing Search Trees. Chapter 11

CS60020: Foundations of Algorithm Design and Machine Learning. Sourangshu Bhattacharya

CS60020: Foundations of Algorithm Design and Machine Learning. Sourangshu Bhattacharya

Advanced Tree Data Structures

DATA STRUCTURES AND ALGORITHMS. Hierarchical data structures: AVL tree, Bayer tree, Heap

CISC 235: Topic 4. Balanced Binary Search Trees

Balanced Search Trees. CS 3110 Fall 2010

Module 4: Index Structures Lecture 13: Index structure. The Lecture Contains: Index structure. Binary search tree (BST) B-tree. B+-tree.

10/23/2013. AVL Trees. Height of an AVL Tree. Height of an AVL Tree. AVL Trees

AVL Trees. See Section 19.4of the text, p

Some Search Structures. Balanced Search Trees. Binary Search Trees. A Binary Search Tree. Review Binary Search Trees

CSI33 Data Structures

LECTURE 18 AVL TREES

CS350: Data Structures AVL Trees

Balanced Binary Search Trees

Properties of red-black trees

ADVANCED DATA STRUCTURES STUDY NOTES. The left subtree of each node contains values that are smaller than the value in the given node.

CSCI 136 Data Structures & Advanced Programming. Lecture 25 Fall 2018 Instructor: B 2

Binary search trees (chapters )

AVL Trees / Slide 2. AVL Trees / Slide 4. Let N h be the minimum number of nodes in an AVL tree of height h. AVL Trees / Slide 6

Balanced Binary Search Trees

AVL Trees Goodrich, Tamassia, Goldwasser AVL Trees 1

Trees. Reading: Weiss, Chapter 4. Cpt S 223, Fall 2007 Copyright: Washington State University

A dictionary interface.

Note that this is a rep invariant! The type system doesn t enforce this but you need it to be true. Should use repok to check in debug version.

Data Structures Lesson 7

B-Trees. Version of October 2, B-Trees Version of October 2, / 22

Algorithms and Data Structures

CSE100. Advanced Data Structures. Lecture 8. (Based on Paul Kube course materials)

Algorithms. Deleting from Red-Black Trees B-Trees

Lecture 5. Treaps Find, insert, delete, split, and join in treaps Randomized search trees Randomized search tree time costs

AVL Tree Definition. An example of an AVL tree where the heights are shown next to the nodes. Adelson-Velsky and Landis

Multi-Way Search Trees

Week 2. TA Lab Consulting - See schedule (cs400 home pages) Peer Mentoring available - Friday 8am-12pm, 12:15-1:30pm in 1289CS

9/29/2016. Chapter 4 Trees. Introduction. Terminology. Terminology. Terminology. Terminology

Multiway Search Trees. Multiway-Search Trees (cont d)

CS Transform-and-Conquer

Ch04 Balanced Search Trees

COMP171. AVL-Trees (Part 1)

CS 261 Data Structures. AVL Trees

Data Structures and Algorithms

Balanced BST. Balanced BSTs guarantee O(logN) performance at all times

Dynamic Access Binary Search Trees

CSCI2100B Data Structures Trees

CSC 172 Data Structures and Algorithms. Fall 2017 TuTh 3:25 pm 4:40 pm Aug 30- Dec 22 Hoyt Auditorium

Algorithms and Data Structures

Balanced Search Trees

Binary search trees (chapters )

Balanced search trees

COMP Analysis of Algorithms & Data Structures

Trees. A tree is a directed graph with the property

Multi-Way Search Trees

Search Trees - 1 Venkatanatha Sarma Y

Trees. Eric McCreath

3137 Data Structures and Algorithms in C++

ECE250: Algorithms and Data Structures AVL Trees (Part A)

COMP Analysis of Algorithms & Data Structures

Efficient Access to Non-Sequential Elements of a Search Tree

Red-black tree. Background and terminology. Uses and advantages

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Priority Queues / Heaps Date: 9/27/17

Balanced search trees. DS 2017/2018

Lesson 21: AVL Trees. Rotation

Algorithms and Data Structures

Lecture 16 Notes AVL Trees

Sorted Arrays. Operation Access Search Selection Predecessor Successor Output (print) Insert Delete Extract-Min

Inf 2B: AVL Trees. Lecture 5 of ADS thread. Kyriakos Kalorkoti. School of Informatics University of Edinburgh

Trees (Part 1, Theoretical) CSE 2320 Algorithms and Data Structures University of Texas at Arlington

Dynamic Access Binary Search Trees

(2,4) Trees Goodrich, Tamassia (2,4) Trees 1

Trees. (Trees) Data Structures and Programming Spring / 28

AVL Trees Heaps And Complexity

Lecture 21: Red-Black Trees

CMPSCI 250: Introduction to Computation. Lecture #14: Induction and Recursion (Still More Induction) David Mix Barrington 14 March 2013

lecture17: AVL Trees

CS 310: Tree Rotations and AVL Trees

Augmenting Data Structures

Lecture 7. Binary Search Trees and Red-Black Trees

Binary Search Trees. Analysis of Algorithms

Uses for Trees About Trees Binary Trees. Trees. Seth Long. January 31, 2010

Introduction. for large input, even access time may be prohibitive we need data structures that exhibit times closer to O(log N) binary search tree

CMPS 2200 Fall 2017 Red-black trees Carola Wenk

Computer Science 210 Data Structures Siena College Fall Topic Notes: Binary Search Trees

AVL Trees. Version of September 6, AVL Trees Version of September 6, / 22

COMP Analysis of Algorithms & Data Structures

Binary Search Trees, etc.

CSE 326: Data Structures Splay Trees. James Fogarty Autumn 2007 Lecture 10

Red-Black trees are usually described as obeying the following rules :

Section 4 SOLUTION: AVL Trees & B-Trees

Algorithms in Systems Engineering ISE 172. Lecture 16. Dr. Ted Ralphs

Module 8: Range-Searching in Dictionaries for Points

COSC160: Data Structures Balanced Trees. Jeremy Bolton, PhD Assistant Teaching Professor

SFU CMPT Lecture: Week 9

Second Examination Solution

Transcription:

Algorithms and Data Structures AVL: Balanced Search Trees Ulf Leser

Content of this Lecture AVL Trees Searching Inserting Deleting Ulf Leser: Alg&DS, Summer Semester 2015 2

History Adelson-Velskii, G. M. and Landis, E. M. (1962). "An information organization algorithm (in Russian)", Doklady Akademia Nauk SSSR. 146: 263 266. Georgi Maximowitsch Adelson-Welski (russ. Георгий Максимович Адельсон-Вельский; weitere gebräuchliche Transkription Adelson- Velsky und Adelson-Velski; * 8. Januar 1922 in Samara) ist ein russischer Mathematiker und Informatiker. Zusammen mit J.M. Landis entwickelte er 1962 die Datenstruktur des AVL-Baums. Er lebt in Ashdod, Israel. Jewgeni Michailowitsch Landis (russ. Евгений Михайлович Ландис; * 6. Oktober 1921 in Charkiw, Ukraine; 12. Dezember 1997 in Moskau) war ein sowjetischer Mathematiker und Informatiker Zusammen mit G. Adelson-Velsky entwickelte Landis 1962 die Datenstruktur des AVL-Baums. Source: http://www.wikipedia.de/ Ulf Leser: Alg&DS, Summer Semester 2015 3

Balanced Trees General search trees: Searching / inserting / deleting is O(log(n)) on average, but O(n) in worst-case Complexity directly depends on tree height Balanced trees are binary search trees with certain constraints on tree height Intuitively: All leaves have similar depth: ~log(n) Accordingly, searching / deleting / inserting is in O(log(n)) Difficulty: Keep the height constraints during tree updates First proposal of balanced trees is attributed to [AVL62] Many others since then: brother-, B-, B*-, BB-, trees Ulf Leser: Alg&DS, Summer Semester 2015 4

AVL Trees Definition An AVL tree T=(V, E) is a binary search tree in which the following constraint holds: v V: height(v.leftchild) - height(v.rightchild) 1 Remarks AVL trees are height balanced Condition does not imply that the level of all leaves differ by at most 1 Will call this constraint height constraint (HC) AVL trees are search trees, i.e., the search constraint (SC) must hold: Right child is larger than parent is larger than left child Ulf Leser: Alg&DS, Summer Semester 2015 5

Examples [source: S. Albers, 2010] AVL? AVL? AVL? Ulf Leser: Alg&DS, Summer Semester 2015 6

Unbalanced Ulf Leser: Alg&DS, Summer Semester 2015 7

Worst-Case Ulf Leser: Alg&DS, Summer Semester 2015 8

Height of an AVL Tree Lemma An AVL tree T with n nodes has height h O(log(n)) Proof by induction We construct AVL trees with the minimal # of nodes (n) at a given height h Let m be the number of leaves h=0 m=1 h=1 m=2 h=2 m>3 h=3 m>5 Ulf Leser: Alg&DS, Summer Semester 2015 9

Height of an AVL Tree Lemma An AVL tree T with n nodes has height h O(log(n)) Proof by induction We construct AVL trees with the minimal # of nodes at a given height h Let m(h) be the minimal number of leaves of an AVL tree of height h It holds: m(h) = m(h-1)+m(h-2) Such maximally unbalanced trees are called Fibonacci-Trees Ulf Leser: Alg&DS, Summer Semester 2015 10

Proof Continued These are exactly the Fibonacci numbers fib 0, 1, 1, 2, 3, 5, 8 Recall (from Fibonacci search) fib( i) ~ 1 5 1+ 2 5 i+ 1 = 1 5 1+ * 2 5 1+ * 2 5 i = c*1,61... i Since h starts at i=2: h+ 2 h h m( h) = fib( h + 2) ~ c*1,61 = c*1,61*1,61*1,61 = c'*1, 61 This yields (recall that n 2m-1, i.e., (n-1)/2 m) n + 1 h 1,61 h log( n) 2c' Ulf Leser: Alg&DS, Summer Semester 2015 11

Content of this Lecture AVL Trees Searching Inserting Deleting Ulf Leser: Alg&DS, Summer Semester 2015 12

Searching in an AVL Tree Searching is in O(log(n)) Follows directly from the worst-case height Note: The best-case height is ceil(log(n)), so best-case and worst-case asymptotically are of the same order Ulf Leser: Alg&DS, Summer Semester 2015 13

Inserting This requires more work The trick is to insert nodes efficiently without hurting the height constraint (HC) We first explain the procedure(s) and then prove that HC always holds after insertion of a node if HC held before this insertion Ulf Leser: Alg&DS, Summer Semester 2015 14

Framework Assume AVL tree T=(V, E) and we want to insert k, k V As usual, we first check whether k V and end in a node v where we know that k cannot be in the subtree rooted at v What are the possible situations? This is one: k <k k<p k p<k Ulf Leser: Alg&DS, Summer Semester 2015 15

Height Constraints k <k k<p k p<k Ulf Leser: Alg&DS, Summer Semester 2015 16

How to Proof the HC Before insertion, HC and SC held Note: k cannot have children We now only look at this particular case Height constraint The height of only one subtree changes left child of p Adding k does not hurt HC in p (because k exists) Thus, HC also holds after insertion Search constraint (we have k <k<p<k ) Since k is larger than k, it must be in the right subtree of k Since k is smaller than p, it must be in the left subtree of p This subtree didn t exit and is created now Thus, SC holds after insertion k <k k k<p p<k Ulf Leser: Alg&DS, Summer Semester 2015 17

The Essential Information Before insertion, HC and SC held Note: k cannot have children We now only look at this particular case Height constraint The height of only one subtree changes left child of p Adding k does not hurt HC in p (because k exists) Thus, HC also holds after insertion Search constraint (we have k <k<p<k ) Since k is larger than k, it must be in the right subtree of k Since k is smaller than p, it must be in the left subtree of p This subtree didn t exit and is created now Thus, SC holds after insertion k <k k k<p p<k Ulf Leser: Alg&DS, Summer Semester 2015 18

Other Cases k<k Also trivial p<k k <p k Problem The left subtree of k changes its height We have to look at the height of the right subtree of k to decide what to do Actually, we only need to know if it is larger, smaller, or equal in height to the left subtree (before insertion) p<k k k<k Ulf Leser: Alg&DS, Summer Semester 2015 19

Abstraction We assume that we found the position of k such that SC holds after insertion We don t need to check from now on its part of the case To check HC, we need to know the height differences in every node that is an ancestor of the new position of k Definition Let T=(V, E) be a tree and p V. We define bal(p) = height( right_child(p)) height( left_child(p)) Clearly, if T is an AVL tree, then p: bal(p) {-1, 0, 1} Ulf Leser: Alg&DS, Summer Semester 2015 20

New Presentation l <k k<k k<k k<p p<k p<k k p<k k <p k k +1-1 0 k 0 0 k k Ulf Leser: Alg&DS, Summer Semester 2015 21

More Systematic Assume AVL tree T=(V, E) and we want to insert k, k V We found the node p under which we want to insert k Three possible cases +1 Case 1: bal(p)=+1 Then there exists a right subtree of p (one node only) We insert k as left child Height of p doesn t change Ancestors of p remain unaffected Adapt bal(p) and we are done k 0 0 0 Ulf Leser: Alg&DS, Summer Semester 2015 22

Case 2 Assume AVL tree T=(V, e) and we want to insert k, k V We found the node p under which we want to insert k Three possible cases -1 Case 2: bal(p)=-1 Then there exists a left subtree of p (one node only) We insert k as right child Height of p doesn t change Ancestors of p remain unaffected Adapt bal(p) and we are done 0 0 0 k Ulf Leser: Alg&DS, Summer Semester 2015 23

Case 3 Assume AVL tree T=(V, e) and we want to insert k, k V We found the node p under which we want to insert k Three possible cases 0 Case 3: bal(p)=0 There is neither a left nor a right subtree of p (p is a leaf) We insert k as left or right child Height of p changes (HC valid?) Ancestors of p are affected Adapt bal(p) and look at parent(p) k? +/-1 k? Ulf Leser: Alg&DS, Summer Semester 2015 24

Up the Tree In case 3 (bal(p)=0) we have to see if HC is hurt in any of the ancestors of p We call a procedure upin(p) recursively We look at the parent p of p We check bal(p ) to see if the height change in p breaks HC in p If not, we are done If yes, we can either fix it locally or have to propagate further up the tree Fixing locally (i.e., with constant work) is the main trick behind AVL trees It implies that we never have to call upin(p) more than O(log(n)) times the height of an AVL tree with n nodes Ulf Leser: Alg&DS, Summer Semester 2015 25

Subcases p can either be the left or the right child of its parent p Note that bal(p) must be +1 or -1 when upin() is called We call this PC, the precondition of upin() In the first call, bal(p)=0 before insertion, thus +1/-1 afterwards In later calls: We have to check Case 3.1 Case 3.2 p p bal(p) {+1,-1} bal(p) {+1,-1} k k Ulf Leser: Alg&DS, Summer Semester 2015 26

Subcases of Case 3.1 Case 3.1.1 (bal(p )=+1) Right subtree of p is higher than left subtree Left subtree has just grown by 1 Thus, height of p doesn t change Adapt bal(p ) and we are done Case 3.1.2 (bal(p )=0) Left and right subtree of p have same height Thus, height of p changes Adapt bal(p ) and call upin(p ) bal(p ) now is -1 PC holds bal(p )=+1 bal(p) {+1,-1} k bal(p )=0 bal(p) {+1,-1} k Ulf Leser: Alg&DS, Summer Semester 2015 27

Subcases of Case 3.1 Case 3.1.3 (bal(p )=-1) Left subtree of p was already higher than right subtree And has even grown further HC is hurt in p Fix locally but how? bal(p) {+1,-1} k bal(p )=-1 Case 3.1.3.1-1 Case 3.1.3.2-1 -1 +1 1 2 3 1 2 3 Ulf Leser: Alg&DS, Summer Semester 2015 28

A Closer Look -1-1 1 2 3 Subtree 1 contains values smaller than p (and than p ) Subtree 2 contains values larger than p, but smaller than p Subtree 3 contains values larger than p (and than p) Can we rearrange the subtree rooted in p such that FC and HC hold? Ulf Leser: Alg&DS, Summer Semester 2015 29

Example 8 4-3 5-7 9- Subtree 1 contains values smaller than p (and than p ) Subtree 2 contains values larger than p, but smaller than p Subtree 3 contains values larger than p (and than p) We change the root node Ulf Leser: Alg&DS, Summer Semester 2015 30

Rotation 8 4 4 8-3 5-7 9- -3 5-7 9- Rotate nodes p and p to the right Ulf Leser: Alg&DS, Summer Semester 2015 31

Rotation 8 4 4 8-3 5-7 9- -3 5-7 9- Rotate nodes p and p to the right Clearly, SC holds Impact on HC? Ulf Leser: Alg&DS, Summer Semester 2015 32

Rotation and HC -1 0-1 0 h h-1 h-1 h h-1 h-1 Before rotation HC hurt in left subtree (height is h+2) versus right subtree (height is h+1) Subtree before insertion had height h+1 Ulf Leser: Alg&DS, Summer Semester 2015 33

Rotation and HC -1 0-1 0 h h-1 h-1 h h-1 h-1 Before rotation HC hurt in left subtree (height is h+2) versus right subtree (height is h+1) Subtree had height h+1 After rotation HC holds Height of subtree unchanged No further upin() Ulf Leser: Alg&DS, Summer Semester 2015 34

Recall Case 3.1.3 Left subtree of p was already higher than right subtree And has even grown HC is hurt in p Fix locally How? bal(p) {+1,-1} Case 3.1.3.1-1 Case 3.1.3.2 k bal(p )=-1-1 -1 +1 1 2 3 1 2 3 Ulf Leser: Alg&DS, Summer Semester 2015 35

More Intricate -1 +1 h-1 h h-1 HC hurt (heights h+2 versus h) If we rotated to the right, p (the new root) would have a left subtree of height h-1 and a right subtree of height h+1 Forbidden by HC We have to break the subtree of height h Ulf Leser: Alg&DS, Summer Semester 2015 36

One More Level of Detail -1-1 +1 = +1 h-1 h h-1 h-1 v h-1 height(v)=h height(x) and height(y) must be h-1 or h-2 (one must be h-1) X h-1 or h-2 Y h-1 or h-2 Since the subtree rooted at p has just grown in height, this growth must have happened below v (because bal(p)=+1), so we must have height(x) height(y) Ulf Leser: Alg&DS, Summer Semester 2015 37

Double Rotation p p p v p h-1 v h-1 h-1 X h-1 or h-2 Y h-1 or h-2 h-1 X h-1 or h-2 Y h-1 or h-2 Ulf Leser: Alg&DS, Summer Semester 2015 38

Double Rotation v p p v p p h-1 h-2 h-1 X h-1 or h-2 Y h-1 or h-2 h-1 X h-1 or h-2 Y h-1 or h-2 Ulf Leser: Alg&DS, Summer Semester 2015 39

AVL Constraints p v h-1 X h-1 or h-2 p Y h-1 or h-2 h-1 Adaptation bal(p) {0, -1} bal(p ) {0, +1} bal(v) = 0 Height constraint Holds in every node Need to call upin(v)? No: Subtree had height h+1 and still has height h+1 Search constraint? Ulf Leser: Alg&DS, Summer Semester 2015 40

Search Constraint p v p p p[ v ]p Uff p ]p ]p,v[ ]v,p [ p[ ]p,v[ ]v,p [ Ulf Leser: Alg&DS, Summer Semester 2015 41

Are we Done? Case 3.2 p bal(p) {+1,-1} Similar solution If bal(p )=-1, adapt and finish If bal(p )=0, adapt and call upin(parent(p ) If bal(p )=+1, then Case 3.2.3.1: Rotate left in p Case 3.2.3.1: Rotate right in p, then rotate left in v k Ulf Leser: Alg&DS, Summer Semester 2015 42

Summary We found the node p under which we want to insert k Major cases If k<p and rightchild(p) null: Insert k (new left child) If k>p and leftchild(p) null: Insert k (new right child) If p has no children: Insert k and call upin(p) Procedure upin(p) If p=leftchild(p ) If bal(p )=1: Set bal(p )=0, done If bal(p )=0: Set bal(p )=-1, call upin(p ) If bal(p )=-1: If bal(p)=-1: Rotate right in p, done If bal(p)=+1: Rotate left in p, right in v, done Else (p=rightchild(p )) Ulf Leser: Alg&DS, Summer Semester 2015 43

Example insert 9 HC hurt in p rotate left in p insert 8 Ulf Leser: Alg&DS, Summer Semester 2015 44

Example p changes height HC hurt in root Rotate left in p, then right in root Ulf Leser: Alg&DS, Summer Semester 2015 45

Content of this Lecture AVL Trees Searching Inserting Deleting Ulf Leser: Alg&DS, Summer Semester 2015 46

Deleting a Key Follows the same scheme as insertions We will be a bit more sloppy than for insertions details can be found in [OW] First find the node p which holds k (to be deleted) We will again find cases where we have to do nothing, cases where we have to rotate, and cases where we have to propagate changes up the tree Ulf Leser: Alg&DS, Summer Semester 2015 47

Major Cases Case 1: k has no children Remove k, adapt bal(p) If bal(p) is set to 0, then height has shrunken by 1 All other cases are easily resolved locally Then call upout(p) Case 2: k has only one child Replace k with k k cannot have children, or HC would not hold in k Height and balance of k (now k ) has changed Call upout(k ) p p k k k Ulf Leser: Alg&DS, Summer Semester 2015 48

Invariant Case 1: k has no children Remove k, adapt bal(p) p bal(p)=0 If bal(p) is set to 0, then height has shrunken by 1 All other cases are easily resolved locally k Height of p decreased by 1 Then call upout(p) Case 2: k has only one child Replace k with k k cannot have children, or HC would not hold in k Height and balance of k (now k ) has changed p k k bal(p)=0 Height of p decreased by 1 Call upout(k ) Ulf Leser: Alg&DS, Summer Semester 2015 49

Case 3 Case 3: k has two children Recall natural search trees We search the symmetric predecessor q of k Replace k with q and call delete(q) (the old one) p q k Ulf Leser: Alg&DS, Summer Semester 2015 50

Procedure upout(p) Whenever we call upout(p), the height of p has decreased by 1 and bal(p)=0 Let p be the left child of its parent p Again, the case of p being the right child of p is symmetric Case 1; bal(p )=-1 bal(p )=-1 bal(p )=0 upout(p) p p h k h h-1 h Ulf Leser: Alg&DS, Summer Semester 2015 51

Procedure upout(p) Whenever we call upout(p), the height of p has decreased by 1 and bal(p)=0 Let p be the left child of its parent p Again, the case of p being the right child of p is symmetric Case 2: bal(p )=0 bal(p )=0 bal(p )=+1 done p p h h+1 k h-1 h+1 Ulf Leser: Alg&DS, Summer Semester 2015 52

Procedure upout(p) Whenever we call upout(p), the height of p has decreased by 1 and bal(p)=0 Let p be the left child of its parent p Again, the case of p being the right child of p is symmetric Case 3: bal(p )=+1 bal(p )=+1 bal(p )=+1 height(q)=height(p)+1 p = p q h k h+2 0 1 2 3 Ulf Leser: Alg&DS, Summer Semester 2015 53

Subcase 1 Case 3.1: bal(q)=0 Rotate left in q bal(q)=-1 bal(p )=+1 bal(p )=0 p bal(q)=0 p 0 1 2 3 0 1 2 3 Height has not changed - done Ulf Leser: Alg&DS, Summer Semester 2015 54

Subcase 2 Case 3.2: bal(q)=+1 Rotate left in q (again) bal(q)=0 bal(p )=+1 bal(p )=0 p bal(q)=+1 p 0 1 2 3 0 1 2 3 Height has changed upout(q) Ulf Leser: Alg&DS, Summer Semester 2015 55

Subcase 3 Case 3.3: bal(q)=-1 Rotate right in q, then left in z bal(z)=0 bal(p )=+1 p q p bal(q)=-1 p 4 0 1 z 4 0 1 2 3 2 3 Height has changed upout(z) Ulf Leser: Alg&DS, Summer Semester 2015 56

Summary AVL Trees With a little work, we reached our goal: Searching, inserting, and deleting is possible in O(log(n)) One can also show that ins/del are in O(1) on average Because reorganizations are rare and usually stop very early AVL trees are a work-horse for keeping a sorted list AVL trees are bad as disk-based DS Disk blocks (b) are much larger than one key, and following a pointer means one head seek Better: B-Trees: Trees of order b with constant height in all leaves B typically ~1000 Finding a key only requires O(log 1000 (n)) seeks Ulf Leser: Alg&DS, Summer Semester 2015 57