CS notes 9

CS notes 9 - AVL Trees Monday, February 21, 2011 4:08 PM...

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

View Full Document Right Arrow Icon
AVL Trees Monday, February 21, 2011 4:08 PM AVL Tree Node Parent Left Data Right Balance factor 1. Search: same as BST 2. Insert o Rebalancing at node x Let Q be child of x in its taller side (Q is root of taller subtree of x) Case 1: Balance factor of x = balance factor of Q Action: Rotate q-x Q becomes new root O(1) [# of pointer changes is independent of # nodes in tree] Case 2: Balance factor of x != balance factor of Q Let R be root of taller subtree of Q Rotate R-Q Rotate R-X Search time O(log n) # of levels is O(log n) Hash Tables Monday, February 28, 2011 3:42 PM Array access = O(1) Start with simplified/small range of keys Key=index This makes searching O(1) since the key is the index in the array Space usage= # of objects in set/range of keys How to fix memory issues? Simplify key so all items can fit in affordable 'table' size
Background image of page 1

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

View Full DocumentRight Arrow Icon
Manipulate key Key->hash function->index in array Store an array of linked lists- keys with same indexes get stored in the same linked lists
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/29/2012 for the course 198 112 taught by Professor Venugopal during the Spring '09 term at Rutgers.

Page1 / 3

CS notes 9 - AVL Trees Monday, February 21, 2011 4:08 PM...

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

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