lec27a - Lecture 27 Balanced Binary Search Trees Ch. 16.1,...

Info iconThis preview shows pages 1–12. Sign up to view the full content.

View Full Document Right Arrow Icon
Lecture 27 Balanced Binary Search Trees Ch. 16.1, 17.1-3
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Balanced Binary Search Trees height is O(log n) , where n is the number of elements in the tree AVL (Adelson-Velsky and Landis) trees red-black trees get, put, and remove take O(log n) time
Background image of page 2
Balanced Binary Search Trees Indexed AVL trees Indexed red-black trees Indexed operations also take O(log n) time
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Balanced Search Trees weight balanced binary search trees 2-3 & 2-3-4 trees AA trees B-trees BBST etc.
Background image of page 4
AVL Tree binary tree for every node x , define its balance factor balance factor of x = height of left subtree of x - height of right subtree of x balance factor of every node x is -1 , 0 , or 1
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Balance Factors 0 0 0 0 1 0 -1 0 1 0 -1 1 -1 This is an AVL tree.
Background image of page 6
Height The height of an AVL tree that has n nodes is at most 1.44 log 2 (n+2) . The height of every n node binary tree is at least log 2 (n+1) .
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
AVL Search Tree 0 0 0 0 1 0 -1 0 1 0 -1 1 -1 10 7 8 3 1 5 30 40 20 25 35 45 60
Background image of page 8
put(9) 0 0 0 0 1 0 -1 0 1 0 -1 1 -1 9 0 -1 0 10 7 8 3 1 5 30 40 20 25 35 45 60
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
put(29) 0 0 0 0 1 0 0 1 0 -1 1 -1 10 7 8 3 1 5 30 40 25 35 45 60 29 0 -1 -2 RR imbalance => new node is in right subtree of right subtree of blue node (node with bf = -2 )
Background image of page 10
put(29) 0 0 0 0 1 0 0 1 0 -1 1 -1 10 7 8 3 1 5 30 40 25 35 45 60 0 RR rotation.
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 12
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/18/2012 for the course COP 3530 taught by Professor Davis during the Fall '08 term at University of Florida.

Page1 / 36

lec27a - Lecture 27 Balanced Binary Search Trees Ch. 16.1,...

This preview shows document pages 1 - 12. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online