notes33 - Name: Sahil Gulati Week: Feb 18th, 20th, 22nd AVL...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
Name: Sahil Gulati Week: Feb 18th, 20th, 22 nd AVL Trees - An AVL tree is a balanced binary tree - For every internal node n of the tree the height of the children of n can differ at most by 1 Height of leafs = 0 Height of n = 1 + max(height of left or right node) 3-1 > 1 Not an AVL tree Height of an AVL tree Proposition: Total height of an AVL tree is O(log n) where n is the number of nodes Proof : Find the tree that has the minimum number of nodes for height h n (h) = number of internal nodes of tree with the minimum number of nodes with height h n (1) = 1 n (2) = 2 n (3) = 4 h
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
In general the AVL tree with height h and minimum number of nodes contains a sub tree of height h-1 and another one of height h-2 with minimum number of nodes n (n) = n (n-1) + n (n-2) + 1 n (n) > n (n-1) + n (n-2) Since n (n-1) > n (n-2) n (h) > 2n (h-2) n (h) > 4n (h-4) n (h) > 8n (h-6) n (h) > 2 i n (h-2i) n (h) > 2 x n (0) h - 2x = 0, x = h/2 n (h) > 2 h/2 log n > h/2 2log n > h h = O(log n) Insertion in an AVL tree
Background image of page 2
Insert (54) - Find position to insert the following path from the root - Insert node instead of the leaf not an AVL tree as } 3 – 1 > 1 - Starting at the inserted node and going upwards to the root rotate the nodes n; the following way if the sub tree of that node is unbalanced - Identify the following nodes z – node that is root to an unbalanced sub tree y – the child of z with the largest height x – the child of y with the largest height
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Rename z, y and x as a, b and c based on the value of the keys from minimum to maximum a b c z x y 50 54 63 - Restructure the tree rooted by c as:
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/02/2012 for the course CS 251 taught by Professor Staff during the Fall '08 term at Purdue University-West Lafayette.

Page1 / 15

notes33 - Name: Sahil Gulati Week: Feb 18th, 20th, 22nd AVL...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online