7.5-avl - CMPT 225 Self-Balancing Trees CMPT 225 AVL Trees...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CMPT 225 Self-Balancing Trees CMPT 225 AVL Trees CMPT 225 BST Activity - 1 • Build BST #1 by performing the following operations: • Insert K, F, G, C, H, A, R, T, U, S, P, D, L, M, N • Remove G and R • Build BST #2 by performing the following operations: • Insert A, C, D, F, H, K, L, M, G, N, P, S, T, U, R • Remove G and R • Draw the resulting BST’s CMPT 225 BST Activity - 2 • Exercises: • How many elements are contained in each resulting BST? • Determine the height of each resulting BST. • Determine the number of levels of each resulting BST. • Which element would you be searching for if you were to perform the “best case” scenario of the search operation in each of these BST's? • What would be the time complexity of this scenario? • Which element would you be searching for if you were to perform the “worst case” scenario of the search operation in each of these BST's? • What would be the time complexity of this scenario? CMPT 225 Some Conclusions • BST insertion and removal algorithms • Only preserve the sort ordering property of the BST • These algorithms do not keep the BST balanced • Therefore, if we insert n elements into a BST and these elements are already in a sorting order (sort ordered by key value), these insertions will produce an unbalanced BST, i.e., a linear data structure, and the search time complexity will degrade to O(n) CMPT 225 • To avoid degeneration of BST into linear data structure, let’s consider a variation of a BST that self-balances itself when insertion/removal operation are performed ... operation are performed ....
View Full Document

This note was uploaded on 01/29/2012 for the course CMPT 225 taught by Professor Annelavergne during the Summer '07 term at Simon Fraser.

Page1 / 31

7.5-avl - CMPT 225 Self-Balancing Trees CMPT 225 AVL Trees...

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

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