12 Splay Trees

12 Splay Trees - Self-adjusting Trees 15-211: Fundamental...

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

View Full Document Right Arrow Icon
Self-adjusting Trees 15-211: Fundamental Data Structures and Algorithms Charlie Garrod 23 February 2010 Reading for today: Weiss 22
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 Announcements HW3 theory due now Programming due Thursday night Quiz 3 in recitation tomorrow Midterm in lecture next Tuesday Handwritten note sheet, 1 page front+back Review session Sunday, 2 pm, location TBA Please review the cheating policy: http://www.cs.cmu.edu/~211/policy/cheating.html
Background image of page 2
3 Last time: 2-3-4 trees Insert(B) S W G Q H A C F S W H A B C G Q F
Background image of page 3

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

View Full DocumentRight Arrow Icon
4 Last time: Red-black trees Each 2-3-4 node corresponds to one black node 2-3-4 node splits correspond to rotations and recolorings B F H D I G G F B H I D D I OR
Background image of page 4
5 Case 1: single right rotation X y A B C X y A B C (to be continued…)
Background image of page 5

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

View Full DocumentRight Arrow Icon
6 Case 1: single right rotation X y A B C X y A B C
Background image of page 6
7 Case 2: double right rotation X y A C D Z B X y A C D Z B (to be continued…)
Background image of page 7

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

View Full DocumentRight Arrow Icon
8 Case 2: double right rotation X y A C D Z B X y A C D Z B
Background image of page 8
9 Dealing with imbalance Balanced trees Maintain structural invariants that guarantee O(lg n ) height AVL trees 2-3-4 and Red-black trees Self-adjusting trees Not necessarily O(lg n ) height, but can show amortized efficiency
Background image of page 9

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

View Full DocumentRight Arrow Icon
10 90-10 rule 90% of the accesses go to 10% of the data
Background image of page 10
11 Today: Self-adjusting trees Rotate-to-root Splay trees Bottom-up splay operation Using splay Top-down splay operation
Background image of page 11

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

View Full DocumentRight Arrow Icon
12 Rotate-to-root When you access a node, use rotations to move it to the root e.g., find (7) 1 3 2 4 6 5 7 1 3 2 4 6 5 7
Background image of page 12
13 Rotate-to-root When you access a node, use rotations to move it to the root e.g., find (7) 1 3 2 4 6 5 7 1 3 2 4 6 5 7 1 3 2 4 6 7 5
Background image of page 13

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

View Full DocumentRight Arrow Icon
14 Rotate-to-root When you access a node, use rotations to move it to the root e.g., find (7) 1 3 2 4 6 5 7 1 3 2 4 6 5 7 1 3 2 4 6 7 5 1 3 2 7 6 4 5 1 7 2 3 6 4 5 1 2 7 3 6 4 5 7 2 1 3 6 4 5
Background image of page 14
Rotate-to-root When you access a node, use rotations to move it to the root
Background image of page 15

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

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

Page1 / 60

12 Splay Trees - Self-adjusting Trees 15-211: Fundamental...

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

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