Depth of an AVL tree Theorem: Any AVL tree with n nodes has height less than 1.441 log n. Proof: Given an n-node AVL tree, we want to find an upper bound.

Slides:



Advertisements
Similar presentations
Trees Chapter 11.
Advertisements

22C:19 Discrete Structures Induction and Recursion Fall 2014 Sukumar Ghosh.
AVL Trees1 Part-F2 AVL Trees v z. AVL Trees2 AVL Tree Definition (§ 9.2) AVL trees are balanced. An AVL Tree is a binary search tree such that.
1 Union-find. 2 Maintain a collection of disjoint sets under the following two operations S 3 = Union(S 1,S 2 ) Find(x) : returns the set containing x.
AVL Trees1 Part-F2 AVL Trees v z. AVL Trees2 AVL Tree Definition (§ 9.2) AVL trees are balanced. An AVL Tree is a binary search tree such that.
Solution of Assignment 3 and Midterm CSC2100B. AVL Tree A binary search tree is a binary tree in which every node has larger key than the nodes in its.
AVL Trees COL 106 Amit Kumar Shweta Agrawal Slide Courtesy : Douglas Wilhelm Harder, MMath, UWaterloo
CSE332: Data Abstractions Lecture 7: AVL Trees Dan Grossman Spring 2010.
CSE332: Data Abstractions Lecture 7: AVL Trees Tyler Robison Summer
Tirgul 5 AVL trees.
TCSS 342 AVL Trees v1.01 AVL Trees Motivation: we want to guarantee O(log n) running time on the find/insert/remove operations. Idea: keep the tree balanced.
Lecture 13 CSE 331 Oct 2, Announcements Please turn in your HW 3 Graded HW2, solutions to HW 3, HW 4 at the END of the class Maybe extra lectures.
CS2420: Lecture 27 Vladimir Kulyukin Computer Science Department Utah State University.
CSE 326: Data Structures AVL Trees
Tirgul 5 Comparators AVL trees. Comparators You already know interface Comparable which is used to compare objects. By implementing the interface, one.
Tirgul 5 This tirgul is about AVL trees. You will implement this in prog-ex2, so pay attention... BTW - prog-ex2 is on the web. Start working on it!
AVL Trees v z. 2 AVL Tree Definition AVL trees are balanced. An AVL Tree is a binary search tree such that for every internal node v of T, the.
TCSS 342 BST v1.01 BST addElement To addElement(), we essentially do a find( ). When we reach a null pointer, we create a new node there. void addElement(Object.
1 B-Trees Section AVL (Adelson-Velskii and Landis) Trees AVL tree is binary search tree with balance condition –To ensure depth of the tree is.
Oct 29, 2001CSE 373, Autumn External Storage For large data sets, the computer will have to access the disk. Disk access can take 200,000 times longer.
Red-Black Trees Red-black trees: –Binary search trees augmented with node color –Operations designed to guarantee that the height h = O(lg n)
Analysis techniques Pasi Fränti Ordo O(g) – Upper Bound f(n) ≤ c∙g(n) Omega  (g)– Lower Bound f(n) ≥ c∙g(n) Theta Θ(g)– Exact limit: c 1 ∙g(n)
1 Trees 4: AVL Trees Section 4.4. Motivation When building a binary search tree, what type of trees would we like? Example: 3, 5, 8, 20, 18, 13, 22 2.
Oct 26, 2001CSE 373, Autumn A Forest of Trees Binary search trees: simple. –good on average: O(log n) –bad in the worst case: O(n) AVL trees: more.
1 Lower Bound on Comparison-based Search We have now covered lots of searching methods –Contiguous Data (Arrays) Sequential search Binary Search –Dynamic.
October 3, 2001CSE 373, Autumn Mathematical Background Exponents X A X B = X A+B X A / X B = X A-B (X A ) B = X AB X N +X N = 2X N 2 N +2 N = 2 N+1.
CSE 3358 NOTE SET 13 Data Structures and Algorithms.
AVL TREES By Asami Enomoto CS 146 AVL Tree is… named after Adelson-Velskii and Landis the first dynamically balanced trees to be propose Binary search.
Dynamic Dictionaries Primary Operations:  get(key) => search  put(key, element) => insert  remove(key) => delete Additional operations:  ascend()
1 Discrete Mathematical Mathematical Induction ( الاستقراء الرياضي )
CSC317 1 Binary Search Trees (binary because branches either to left or to right) Operations: search min max predecessor successor. Costs? Time O(h) with.
DAST Tirgul 6. What is a Binary Search Tree? The keys in a binary search tree (BST) are always stored in such a way as to satisfy the search property:
BSTs, AVL Trees and Heaps Ezgi Shenqi Bran. What to know about Trees? Height of a tree Length of the longest path from root to a leaf Height of an empty.
Nov 2, 2001CSE 373, Autumn Hash Table example marking deleted items + choice of table size.
AVL Tree: Balanced Binary Search Tree 9.
1 Section 4.4 Inductive Proof What do we believe about nonempty subsets of N? Since  N, <  is well-founded, and in fact it is linear, it follows that.
1 Mathematical Induction An inductive proof has three parts: –Basis case –Inductive hypothesis –Inductive step Related to recursive programming.
CSE332: Data Abstractions Lecture 7: AVL Trees
DAST Tirgul 7.
CSE 373, Copyright S. Tanimoto, 2002 Binary Search Trees -
Lec 13 Oct 17, 2011 AVL tree – height-balanced tree Other options:
BCA-II Data Structure Using C
Heaps (8.3) CSE 2011 Winter May 2018.
Binary Search Trees A binary search tree is a binary tree
AVL Trees 6/25/2018 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M.
AVL Trees A BST in which, for any node, the number of levels in its two subtrees differ by at most 1 The height of an empty tree is -1. If this relationship.
Red-Black Trees 9/12/ :44 AM AVL Trees v z AVL Trees.
MA/CSSE 473 Day 21 AVL Tree Maximum height 2-3 Trees
AVL Trees 4/29/15 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M. H.
Red-Black Trees 11/13/2018 2:07 AM AVL Trees v z AVL Trees.
AVL Trees CENG 213 Data Structures.
Multi-Way Search Trees
Red-Black Trees 11/26/2018 3:42 PM AVL Trees v z AVL Trees.
Red-Black Trees 2018年11月26日3时46分 AVL Trees v z AVL Trees.
v z Chapter 10 AVL Trees Acknowledgement: These slides are adapted from slides provided with Data Structures and Algorithms in C++, Goodrich,
CSE373: Data Structures & Algorithms Lecture 5: AVL Trees
CSE 373, Copyright S. Tanimoto, 2002 Binary Search Trees -
CS223 Advanced Data Structures and Algorithms
CSE 332: Data Abstractions AVL Trees
CS223 Advanced Data Structures and Algorithms
Red-Black Trees 2/24/ :17 AM AVL Trees v z AVL Trees.
Lecture 9: Self Balancing Trees
Data Structures Lecture 21 Sohail Aslam.
Induction Chapter
BST Insert To insert an element, we essentially do a find( ). When we reach a NULL pointer, we create a new node there. void BST::insert(const Comp &
Red-Black Trees 5/19/2019 6:39 AM AVL Trees v z AVL Trees.
Tutorial 2 - Daniel Razavi
Chapter 11 Trees © 2011 Pearson Addison-Wesley. All rights reserved.
CS210- Lecture 19 July 18, 2005 Agenda AVL trees Restructuring Trees
Presentation transcript:

Depth of an AVL tree Theorem: Any AVL tree with n nodes has height less than 1.441 log n. Proof: Given an n-node AVL tree, we want to find an upper bound on the height of the tree. Fix h. What is the smallest n such that there is an AVL tree of height h with n nodes? Let Wh be the set of all AVL trees of height h that have as few nodes as possible. Oct 24, 2001 CSE 373, Autumn 2001

Let wh be the number of nodes in any one of these trees. w0 = 1, w1 = 2 Suppose T  Wh, where h  2. Let TL and TR be T’s left and right subtrees. Since T has height h, either TL or TR has height h-1. Suppose it’s TR. By definition, both TL and TR are AVL trees. In fact, TR  Wh-1or else it could be replaced by a smaller AVL tree of height h-1 to give an AVL tree of height h that is smaller than T. Oct 24, 2001 CSE 373, Autumn 2001

Therefore, wh = 1 + wh-2 + wh-1 . Similarly, TL  Wh-2. Therefore, wh = 1 + wh-2 + wh-1 . Claim: For h  0, wh  h , where  = (1 + 5) / 2  1.6. Proof: The proof is by induction on h. Basis step: h=0. w0 = 1 = 0. h=1. w1 = 2 > 1. Induction step: Suppose the claim is true for 0  m  h, where h  1. Oct 24, 2001 CSE 373, Autumn 2001

From the claim, in an n-node AVL tree of height h, Then wh+1 = 1 + wh-1 + wh  1 + h-1 + h (by the i.h.) = 1 + h-1 (1 + ) = 1 + h+1 (1+ = 2) > h+1 Thus, the claim is true. From the claim, in an n-node AVL tree of height h, n  wh  h (from the Claim) h  log  n = (log n) / (log ) < 1.441 log n Oct 24, 2001 CSE 373, Autumn 2001