This preview shows pages 1–7. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: CMPT 225 SelfBalancing 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 selfbalances 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.
 Summer '07
 AnneLavergne

Click to edit the document details