麻省理工学院:《算法导论》(英文版) Lecture 10 Prof erik demaine

Introduction to Algorithms 6.046J/18.401J/SMA5503 Lecture 10 Prof erik demaine
Introduction to Algorithms 6.046J/18.401J/SMA5503 Lecture 10 Prof. Erik Demaine

Balanced search trees Balanced search tree. a search-tree data structure for which a height of o(g n)is guaranteed when implementing a dynamic set of n items avl trees 2-3 trees Examples: 2-3-4 trees ●B- trees ●Red- black trees o 2001 by Charles E Leiserson Introduction to Algorithms Day 18 L10.2
© 2001 by Charles E. Leiserson Introduction to Algorithms Day 18 L10.2 Balanced search trees Balanced search tree: A search-tree data structure for which a height of O(lg n) is guaranteed when implementing a dynamic set of n items. Examples: • AVL trees • 2-3 trees • 2-3-4 trees • B-trees • Red-black trees

Red black trees This data structure requires an extra one- bit color field in each node Red-black properties I. Every node is either red or black 2. The root and leaves(nil's)are black 3. If a node is red then its parent is black 4. All simple paths from any node x to a descendant leaf have the same number of black nodes= black-height(x) o 2001 by Charles E Leiserson Introduction to Algorithms Day 18 L10.3
© 2001 by Charles E. Leiserson Introduction to Algorithms Day 18 L10.3 Red-black trees This data structure requires an extra onebit color field in each node. Red-black properties: 1. Every node is either red or black. 2. The root and leaves (NIL’s) are black. 3. If a node is red, then its parent is black. 4. All simple paths from any node x to a descendant leaf have the same number of black nodes = black-height(x)

Example of a red-black tree 7 18 NILNIL 10 h=4 26 NIL NIL NILNIL NIL NIL o 2001 by Charles E Leiserson Introduction to Algorithms Day 18 L10.4
© 2001 by Charles E. Leiserson Introduction to Algorithms Day 18 L10.4 Example of a red-black tree h = 4 88 1111 1010 1818 2626 2222 33 77 NIL NIL NIL NIL NIL NIL NIL NIL NIL

Example of a red-black tree 7 18 NILNIL 10 26 NIL NIL NILNIL NIL NIL 1. Every node is either red or black o 2001 by Charles E Leiserson Introduction to Algorithms Day 18 L10.5
© 2001 by Charles E. Leiserson Introduction to Algorithms Day 18 L10.5 Example of a red-black tree 88 1111 1010 1818 2626 2222 33 77 NIL NIL NIL NIL NIL NIL NIL NIL NIL 1. Every node is either red or black

Example of a red-black tree 7 18 NILNIL 10 26 NIL NIL NILNIL NIL NIL 2. The root and leaves(NILs)are black o 2001 by Charles E Leiserson Introduction to Algorithms Day 18 L10.6
© 2001 by Charles E. Leiserson Introduction to Algorithms Day 18 L10.6 Example of a red-black tree 88 1111 1010 1818 2626 2222 33 77 NIL NIL NIL NIL NIL NIL NIL NIL NIL 2. The root and leaves (NIL’s) are black

Example of a red-black tree 7 18 NILNIL 10 26 NIL NIL NILNIL NIL NIL 3. If a node is red then its parent is black o 2001 by Charles E Leiserson Introduction to Algorithms Day 18 L10.7
© 2001 by Charles E. Leiserson Introduction to Algorithms Day 18 L10.7 Example of a red-black tree 88 1111 1010 1818 2626 2222 33 77 NIL NIL NIL NIL NIL NIL NIL NIL NIL 3. If a node is red, then its parent is black

Example of a red-black tree 7)bh=2 18)bh=2 NILNIL b=1(10 bh=1(8 26 hh=0 NILNIL NIL NIL NIL NIL 4. All simple paths from any node x to a descendant leaf have the same number of black nodes black-height(x) o 2001 by Charles E Leiserson Introduction to Algorithms Day 18 L10.8
© 2001 by Charles E. Leiserson Introduction to Algorithms Day 18 L10.8 Example of a red-black tree 4. All simple paths from any node x to a descendant leaf have the same number of black nodes = black-height(x). 88 1111 1010 1818 2626 2222 33 77 NIL NIL NIL NIL NIL NIL NIL NIL NIL bh = 2 bh = 1 bh = 1 bh = 2 bh = 0

Height of a red-black tree Theorem. a red-black tree with n keys has height h≤21g(n+1) Proof. (The book uses induction. Read carefully. INTUITION. Merge red nodes into their black parents o 2001 by Charles E Leiserson Introduction to Algorithms Day 18 L10.9
© 2001 by Charles E. Leiserson Introduction to Algorithms Day 18 L10.9 Height of a red-black tree Theorem. A red-black tree with n keys has height h ≤ 2 lg(n + 1). Proof. (The book uses induction. Read carefully.) INTUITION: • Merge red nodes into their black parents

Height of a red-black tree Theorem. a red-black tree with n keys has height h≤21g(n+1) Proof. (The book uses induction. Read carefully. INTUITION. Merge red nodes into their black parents o 2001 by Charles E Leiserson Introduction to Algorithms Day18L10.10
© 2001 by Charles E. Leiserson Introduction to Algorithms Day 18 L10.10 Height of a red-black tree Theorem. A red-black tree with n keys has height h ≤ 2 lg(n + 1). Proof. (The book uses induction. Read carefully.) INTUITION: • Merge red nodes into their black parents
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 麻省理工学院:《算法导论》(英文版) Lecture 9 Prof charles e. leiserson.pdf
- 麻省理工学院:《算法导论》(英文版) Lecture 8 Prof charles e. leiserson.pdf
- 麻省理工学院:《算法导论》(英文版) Lecture 7 Prof charles e. leiserson.pdf
- 麻省理工学院:《算法导论》(英文版) Lecture 6 Prof erik demaine.pdf
- 麻省理工学院:《算法导论》(英文版)Lecture 5 Prof erik demaine.pdf
- 麻省理工学院:《算法导论》(英文版)Lecture 4 Prof. charles e. leiserson.pdf
- 麻省理工学院:《算法导论》(英文版) Lecture 3 Prof erik demaine.pdf
- 麻省理工学院:《算法导论》(英文版) Lecture 2 Prof erik demaine.pdf
- 麻省理工学院:《算法导论》(英文版) Lecture Prof. Charles E. Leiserson.pdf
- 桂林电子科技大学:《可编程ASIC原理》课程教学资源(实验指导书)实验二 波形输入与仿真实现.pdf
- 桂林电子科技大学:《可编程ASIC原理》课程教学资源(实验指导书)综合、设计性实验指导书.pdf
- 桂林电子科技大学:《可编程ASIC原理》课程教学资源(实验指导书)封面.pdf
- 桂林电子科技大学:《可编程ASIC原理》课程教学资源(实验指导书)附录GW48EDA系统使用说明.pdf
- 桂林电子科技大学:《可编程ASIC原理》课程教学资源(实验指导书)实验一 可编程ASIC使用初步.pdf
- 桂林电子科技大学:《可编程ASIC原理》课程教学资源(实验指导书)实验五 A/D采样电路设计.pdf
- 桂林电子科技大学:《可编程ASIC原理》课程教学资源(实验指导书)实验四 只读存储器设计.pdf
- 桂林电子科技大学:《可编程ASIC原理》课程教学资源(实验指导书)实验三 序列信号发生器与序列信号检测器的设计.pdf
- 桂林电子科技大学:《可编程ASIC原理》课程教学资源(实验指导书)实验六 数字电压表设计.pdf
- 《数字平面艺术设计》课程教学资源(试卷习题)试题库.doc
- 华中科技大学:《MATLAB语言与控制系统仿真》课程教学资源(PPT课件讲稿)第四章 控制系统的分析方法.ppt
- 麻省理工学院:《算法导论》(英文版) Lecture 11 Prof erik demaine.pdf
- 麻省理工学院:《算法导论》(英文版) Lecture 12 Prof erik demaine.pdf
- 麻省理工学院:《算法导论》(英文版)Lecture 13 Prof erik demaine.pdf
- 麻省理工学院:《算法导论》(英文版) Lecture 14 Prof charles e. leiserson.pdf
- 麻省理工学院:《算法导论》(英文版) Lecture 15 Prof charles e. leiserson.pdf
- 麻省理工学院:《算法导论》(英文版) Lecture 16 Prof charles e. leiserson.pdf
- 麻省理工学院:《算法导论》(英文版)Lecture 17 Prof erik demaine.pdf
- 麻省理工学院:《算法导论》(英文版) Lecture 18 Prof erik demaine.pdf
- 麻省理工学院:《算法导论》(英文版) Lecture 19 Prof erik demaine.pdf
- 麻省理工学院:《算法导论》(英文版) Lecture 20 Prof erik demaine.pdf
- 麻省理工学院:《算法导论》(英文版) Lecture 21 Prof charles e. leiserson.pdf
- 麻省理工学院:《算法导论》(英文版) Lecture 22 Prof charles e. leiserson.pdf
- 麻省理工学院:《算法导论》(英文版) Lecture 23 Prof charles e. leiserson.pdf
- 《计算机三级网络技术》第一章 计算机基础知识.doc
- 《计算机三级网络技术》第七章 电子商务和电子政务.doc
- 《计算机三级网络技术》第三章 局域网基础.doc
- 《计算机三级网络技术》第二章 网络基本概念.doc
- 《计算机三级网络技术》第五章 因特网基础.doc
- 《计算机三级网络技术》第八章 网络技术展望.doc
- 《计算机三级网络技术》第六章 网络安全技术.doc