AA Trees.

Slides:



Advertisements
Similar presentations
AA Trees another alternative to AVL trees. Balanced Binary Search Trees A Binary Search Tree (BST) of N nodes is balanced if height is in O(log N) A balanced.
Advertisements

Balanced Binary Search Trees
Balanced Search Trees. 2-3 Trees Trees Red-Black Trees AVL Trees.
A balanced life is a prefect life.
Trees and Red-Black Trees Gordon College Prof. Brinton.
Self-Balancing Search Trees Chapter 11. Chapter 11: Self-Balancing Search Trees2 Chapter Objectives To understand the impact that balance has on the performance.
Self-Balancing Search Trees Chapter 11. Chapter Objectives  To understand the impact that balance has on the performance of binary search trees  To.
Balanced Trees. Binary Search tree with a balance condition Why? For every node in the tree, the height of its left and right subtrees must differ by.
Binary Search Trees Chapter 7 Objectives
By : Budi Arifitama Pertemuan ke Objectives Upon completion you will be able to: Create and implement binary search trees Understand the operation.
Balanced Trees AVL Trees Red-Black Trees 2-3 Trees Trees.
Analysis of Red-Black Tree Because of the rules of the Red-Black tree, its height is at most 2log(N + 1). Meaning that it is a balanced tree Time Analysis:
Beyond (2,4) Trees What do we know about (2,4)Trees? Balanced
Min Chen School of Computer Science and Engineering Seoul National University Data Structure: Chapter 8.
Chapter 13 B Advanced Implementations of Tables – Balanced BSTs.
Advanced Data Structures and Implementation Top-Down Splay Trees Top-Down Splay Trees Red-Black Trees Red-Black Trees Top-Down Red Black Trees Top-Down.
Chapter 13 A Advanced Implementations of Tables. © 2004 Pearson Addison-Wesley. All rights reserved 13 A-2 Balanced Search Trees The efficiency of the.
Lecture 11COMPSCI.220.FS.T Balancing an AVLTree Two mirror-symmetric pairs of cases to rebalance the tree if after the insertion of a new key to.
1 Chapter 7 Objectives Upon completion you will be able to: Create and implement binary search trees Understand the operation of the binary search tree.
Balanced Search Trees Chapter 19 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Data Structures: A Pseudocode Approach with C, Second Edition 1 Chapter 7 Objectives Create and implement binary search trees Understand the operation.
Red-Black Trees an alternative to AVL trees. Balanced Binary Search Trees A Binary Search Tree (BST) of N nodes is balanced if height is in O(log N) A.
COSC 2007 Data Structures II Chapter 13 Advanced Implementation of Tables II.
Binary Search Trees Chapter 7 Objectives
Balanced Search Trees 2-3 Trees AVL Trees Red-Black Trees
Lecture 23 Red Black Tree Chapter 10 of textbook
File Organization and Processing Week 3
Red-Black Tree Neil Tang 02/04/2010
G64ADS Advanced Data Structures
Red-Black Trees v z Red-Black Trees Red-Black Trees
Search Trees.
Red Black Trees
CS202 - Fundamental Structures of Computer Science II
Lecture 17 Red-Black Trees
CS202 - Fundamental Structures of Computer Science II
Red-Black Trees v z Red-Black Trees 1 Red-Black Trees
Red-Black Trees 9/12/ :44 AM AVL Trees v z AVL Trees.
Lecture 22 Binary Search Trees Chapter 10 of textbook
Red-Black Trees Bottom-Up Deletion.
Red-Black Trees Bottom-Up Deletion.
Binary Search Tree In order Pre order Post order Search Insertion
(edited by Nadia Al-Ghreimil)
AVL Trees 11/10/2018 AVL Trees v z AVL Trees.
Red-Black Trees 11/13/2018 2:07 AM AVL Trees v z AVL Trees.
TCSS 342, Winter 2006 Lecture Notes
Wednesday, April 18, 2018 Announcements… For Today…
Red-Black Trees v z Red-Black Trees 1 Red-Black Trees
CS202 - Fundamental Structures of Computer Science II
Red-Black Trees v z /20/2018 7:59 AM Red-Black Trees
Red-Black Trees v z Red-Black Trees Red-Black Trees
Red-Black Trees 11/26/2018 3:42 PM AVL Trees v z AVL Trees.
CS202 - Fundamental Structures of Computer Science II
Search Sorted Array: Binary Search Linked List: Linear Search
Red-Black Trees Bottom-Up Deletion.
2-3-4 Trees Red-Black Trees
Red-Black Trees v z /17/2019 4:20 PM Red-Black Trees
Red-Black Trees Bottom-Up Deletion.
(edited by Nadia Al-Ghreimil)
AVL Trees 2/23/2019 AVL Trees v z AVL Trees.
CS202 - Fundamental Structures of Computer Science II
Red-Black Trees 2/24/ :17 AM AVL Trees v z AVL Trees.
short illustrative repetition
Red Black Trees (Guibas Sedgewick 78)
Red-Black Implementation of 2-3 Trees
Red-black tree properties
Red-Black Trees 5/19/2019 6:39 AM AVL Trees v z AVL Trees.
1 Lecture 13 CS2013.
CS202 - Fundamental Structures of Computer Science II
Red-Black Trees v z /6/ :10 PM Red-Black Trees
CS202 - Fundamental Structures of Computer Science II
Presentation transcript:

AA Trees

Balanced Binary Search Trees A Binary Search Tree (BST) of N nodes is balanced if height is in O(log N) A balanced tree supports efficient operations, since most operations only have to traverse one or two root-to-leaf paths. There are many implementations of balanced BSTs, including AVL trees, Red-Black trees and AA trees.

Properties of AA Trees An AA tree satisfies the properties of Red-Black trees plus one more: 1 Every node is colored either red or black 2 The root is black 3 If a node is red, both of its children are black. 4 Every path from a node to a null reference has the same number of black nodes 5 Left children may NOT be red

Advantage of AA Trees AA trees simplify the algorithms It eliminates half the restructuring cases It simplifies deletion by removing an annoying case if an internal node has only one child, that child must be a red right child We can always replace a node with the smallest child in the right subtree [it will either be a leaf or have a red child]

Representing the Balance information In each node we store a level. The level is defined by these rules If a node is a leaf, its level is 1 If a node is red, its level is the level of its parent If a node is black, its level is one less than the level of its parent The level is the number of left links to a null reference.

Links in an AA tree A horizontal link is a connection between a node and a child with equal levels Horizontal links are right references There cannot be two consecutive horizontal links Nodes at level 2 or higher must have two children If a node has no right horizontal link, its two children are at the same level

Example of an AA Tree 70 30 15 50 60 85 80 90 35 40 55 65 5 10 20

Insertion A new item is always inserted at the bottom level In the previous example, inserting 2 will create a horizontal left link In the previous example, inserting 45 generates consecutive right links After inserting at the bottom level, we may need to perform rotations to restore the horizontal link properties

skew - remove left horizontal links P X P X A B C A B C

split - remove consecutive horizontal links X P G X G A B A B

skew/split A skew removes a left horizontal link A skew might create consecutive right horizontal links We should first process a skew and then a split, if necessary After a split, the middle node increases a level, which may create a problem for the original parent