recitation04

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

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

View Full Document Right Arrow Icon
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 .
Background image of page 1

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

View Full DocumentRight Arrow Icon
6.006 Recitation Build 2008.7
Background image of page 2
Outline Basic concepts review AVL algorithms Python implementation for AVLs
Background image of page 3

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

View Full DocumentRight Arrow Icon
BST Invariants Binary rooted tree All left descendants have keys < node’s key All right descendants have keys > node’s key 8 3 10 6 1 14 4 7 13
Background image of page 4
Node Height Leaves: height = 0 Inner nodes: height = max(children height) +1 Null tree: height = -1 Rationale: 8 3 10 6 1 14 4 7 13 a subtree operation takes O(h) time
Background image of page 5

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

View Full DocumentRight Arrow Icon
Node Height Leaves: height = 0 Inner nodes: height = max(children height) +1 Null tree: height = -1 Rationale: 8 3 10 6 1 14 4 7 13 0 0 0 0 a subtree operation takes O(h) time
Background image of page 6
Node Height Leaves: height = 0 Inner nodes: height = max(children height) +1 Null tree: height = -1 Rationale: 8 3 10 6 1 14 4 7 13 0 0 0 0 1 1 a subtree operation takes O(h) time
Background image of page 7

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

View Full DocumentRight Arrow Icon
Node Height Leaves: height = 0 Inner nodes: height = max(children height) +1 Null tree: height = -1 Rationale: 8 3 10 6 1 14 4 7 13 0 0 0 0 1 1 2 a subtree operation takes O(h) time
Background image of page 8
Node Height Leaves: height = 0 Inner nodes: height = max(children height) +1 Null tree: height = -1 Rationale: 8 3 10 6 1 14 4 7 13 0 0 0 0 1 1 2 2 a subtree operation takes O(h) time
Background image of page 9

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

View Full DocumentRight Arrow Icon
Node Height Leaves: height = 0 Inner nodes: height = max(children height) +1 Null tree: height = -1 Rationale: 8 3 10 6 1 14 4 7 13 0 0 0 0 1 1 2 2 3 a subtree operation takes O(h) time
Background image of page 10
Balanced Trees Small tree height means fast operations Pack many nodes in trees with low heights Perfectly balanced tree: 2 h+1 - 1 nodes We only care about asymptotic notation Nodes = f(height) must be exponential
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.

Page1 / 60

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

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