lec4 - MIT OpenCourseWare http://ocw.mit.edu 6.006...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

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

Unformatted text preview: MIT OpenCourseWare http://ocw.mit.edu 6.006 Introduction to Algorithms Spring 2008 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms . Lecture 4 Balanced Binary Search Trees 6.006 Spring 2008 Lecture 4: Balanced Binary Search Trees Lecture Overview The importance of being balanced AVL trees Definition Balance Insert Other balanced trees Data structures in general Readings CLRS Chapter 13. 1 and 13. 2 (but different approach: red-black trees) Recall: Binary Search Trees (BSTs) rooted binary tree each node has key left pointer right pointer parent pointer See Fig. 1 65 41 20 11 50 29 26 3 2 1 1 Figure 1: Heights of nodes in a BST 1 Lecture 4 Balanced Binary Search Trees 6.006 Spring 2008 x x x Figure 2: BST property BST property (see Fig. 2). height of node = length ( edges) of longest downward path to a leaf (see CLRS B.5 for details). The Importance of Being Balanced: BSTs support insert, min, delete, rank, etc. in O ( h ) time, where h = height of tree (= height of root). h is between lg( n ) and n : Fig. 3). vs. Perfectly Balanced Path Figure 3: Balancing BSTs balanced BST maintains h = O (lg n ) all operations run in O (lg n ) time. 2 Lecture 4 Balanced Binary Search Trees 6.006 Spring 2008 AVL Trees: Definition...
View Full Document

Page1 / 9

lec4 - MIT OpenCourseWare http://ocw.mit.edu 6.006...

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

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