《算法入门》(英文版)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 1 Prof. Charles E. Leiserson.pdf
- 《城市设计实例—步行商业》杭州湖滨旅游商贸特色街区.ppt
- 《教育心理学》(英文版)Theories Operant Conditioning.ppt
- 《教育心理学》(英文版)Theories:Operant Conditioning.ppt
- 《教育心理学》(英文版)Pavlov and Waston.ppt
- 《教育心理学》(英文版)Behavioral Learning Theories(Thorndike).ppt
- 《教育心理学》(英文版)Bandura’s Social Learning Theory.ppt
- 《教育心理学》(英文版)Learning:introduction.ppt
- 《教育心理学》(英文版)Behavioral Learning Theories.ppt
- 《教育心理学》(英文版)Theories of Development.ppt
- 《教育心理学》(英文版)The history and development of E P.ppt
- 《教育心理学》(英文版)Educational Psychology.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
- 《加快林业建设—缓解气候变化》讲义.ppt
- 哈佛大学:《有机过渡金属化学》英文教学资源(讲义)Alkene/Alkyne Hydrozirconation.pdf
- 哈佛大学:《有机过渡金属化学》英文教学资源(讲义)Olefin functionalization via metal promoted Nu attack.pdf
- 哈佛大学:《有机过渡金属化学》英文教学资源(讲义)Murai has described the synthesis.pdf
- 哈佛大学:《有机过渡金属化学》英文教学资源(讲义)π-Trimethylenemethane cyclization.pdf
- 哈佛大学:《有机过渡金属化学》英文教学资源(讲义)Functionalization of terminal olefins.pdf
- 哈佛大学:《有机过渡金属化学》英文教学资源(讲义)Course Overviewweek1.pdf