算法导论lecture7简介第7讲回顾二叉搜索树运营走.pdfVIP

  • 0
  • 0
  • 约3.08万字
  • 约 68页
  • 2023-09-05 发布于北京
  • 举报

算法导论lecture7简介第7讲回顾二叉搜索树运营走.pdf

Recap • Binary-Search Trees • Operations – Walk – Search, Minimum, um – Insert, delete 2 Today • Red-black trees • Rotations • Insertion • Deletion • AVL-Trees 3 Balanced Search Trees • Worst case height in unbalanced search trees is O(n). A B C D • Balanced search trees guarantee height O(lgn). • Many kinds of balanced trees. 4 Rotation B A g Right a b Rotation 5 Rotation A B a Left Rotation b g 6 Rotation • Basic operation for maintaining balanced trees. • Maintains “inorder” key ordering: a ˛a,b ˛b,c ˛g we have a £A £b £B £c • Depth(a) decrease by 1. • Depth(b) stays same. • Depth( g) reases by 1. • Rotation takes O(1) time. 7 Le

文档评论(0)

1亿VIP精品文档

相关文档