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 B-Trees) 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 29-4, 29-6 and 29-8. B-Trees have several orders and we will learn about two of these versions before formally defining a general B-Tree. 2-3 Trees Definition : A 2-3 tree is a search tree whose interior nodes must have wither 2 or 3 children. All leaves occur at the lowest level. A 2-node has 1 data, 2 links (one data breaks the number line into two parts) A 3-node has 2 data, 3 links (two points breaks numbers into 3 parts) Task 2: To help understand how to use (search) a 2-3 tree, do exercise #12 on page 722 before reviewing the example to create a 2-3 tree below....
View Full Document
- Spring '11
- Wy, B-tree