AVL Data Structure: Balanced Binary Search Trees, Study notes of Computer Science

The avl data structure is a self-balancing binary search tree where the height difference of two subtrees of any node is at most 1. The structure of avl trees, their operations (insert and delete), and how they differ from regular bsts.

Typology: Study notes

2010/2011

Uploaded on 05/08/2011

swapnily
swapnily 🇺🇸

3 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
AVL Data Structure
Binary Trees with Height of O (log2n) AVL representation of BST.
oThe difference in height of the two AVL trees of any node in an AVL is at most equal to 1.
oHeight-balanced 1-tree
+ BST.
oElements/Nodes:
Structure BST + Height-balanced-10Ture:
Operations: Insert and Delete operations are different when compared with BST
equivalents.
(if 0, then same balance)
(if +. Then right sub-tree taller than 1. ) If (-), then left sub-tree is smaller.
Insert
o1.) performs the BST insert operation as if the tree was an ordinary BST.
o2.) Reorganize the tree to get an AVL Tree.
Three Cases:
Case 1.) Find the node on the search path whose balance field is either
(-)or (+) & is closest of the new node. This node is called the pivot node.
B-Tree
Each node, excluding the root node in a b-tree contains between d and 2d elements, where d is
the order of the tree.
The root node contains between 1 & 2d elements. Elements are in sorted order in each node.
Each node, except the root node has a unique parent. Each note except the leaf nodes has one
more child than the number of elements it contains.
Designed with hard-drive efficient in mind.
B-tree are empty initially.
oIf we were to create a B-tree of order 2.

Partial preview of the text

Download AVL Data Structure: Balanced Binary Search Trees and more Study notes Computer Science in PDF only on Docsity!

AVL Data Structure  Binary Trees with Height of O (log2n) AVL representation of BST. o The difference in height of the two AVL trees of any node in an AVL is at most equal to 1. o Height-balanced 1-tree  + BST. o Elements/Nodes:  Structure BST + Height-balanced-10Ture:  Operations: Insert and Delete operations are different when compared with BST equivalents.  (if 0, then same balance)  (if +. Then right sub-tree taller than 1. ) If (-), then left sub-tree is smaller.  Insert o 1.) performs the BST insert operation as if the tree was an ordinary BST. o 2.) Reorganize the tree to get an AVL Tree.  Three Cases:  Case 1.) Find the node on the search path whose balance field is either (-)or (+) & is closest of the new node. This node is called the pivot node.  B-Tree  Each node, excluding the root node in a b-tree contains between d and 2d elements, where d is the order of the tree.  The root node contains between 1 & 2d elements. Elements are in sorted order in each node.  Each node, except the root node has a unique parent. Each note except the leaf nodes has one more child than the number of elements it contains.  Designed with hard-drive efficient in mind.  B-tree are empty initially. o If we were to create a B-tree of order 2.