recitation04

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

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

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

View Full Document
6.006 Recitation Build 2008.7
Outline Basic concepts review AVL algorithms Python implementation for AVLs

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

View Full Document
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
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

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

View Full Document
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
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

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

View Full Document
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
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

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

View Full Document
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
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

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## 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
Ask a homework question - tutors are online