This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Week 15: B alanced Trees Some of the material covered is contained in Chapter 25 and the rest is in Chapter 29. Shape effects the efficiency of searching a bst: best case: O(log n) worst case: O(n) This chapter addresses this issue with two major strategies: 1. adjust a tree that is out of balance (includes AVL trees) 2. keep the tree always in balance (includes BTrees) The second strategy that has more far ranging applications, given limited time is the priority covered here. Definition : The balance factor of a node bf(n) = height(n.left)  height(n.right) Definition : A binary search tree is said to be AVL or height balanced if bf(root) = 0, 1 or 1 Task 1: Briefly review (skim headings and diagrams) the single left and right, and the double rotations so that you are generally aware of this concepts such as figures 294, 296 and 298. BTrees have several orders and we will learn about two of these versions before formally defining a general BTree. 23 Trees Definition : A 23 tree is a search tree whose interior nodes must have wither 2 or 3 children. All leaves occur at the lowest level. A 2node has 1 data, 2 links (one data breaks the number line into two parts) A 3node has 2 data, 3 links (two points breaks numbers into 3 parts) Task 2: To help understand how to use (search) a 23 tree, do exercise #12 on page 722 before reviewing the example to create a 23 tree below....
View Full
Document
 Spring '11
 METZLER

Click to edit the document details