DS-chapter4(Splay Tree,B tree)

DS-chapter4(Splay Tree,B tree) - 4.5 Splay Trees Target :...

Info iconThis preview shows pages 1–4. 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
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 4.5 Splay Trees Target : Any M consecutive tree operations starting from an empty tree take at most O( M log N ) time. Does it mean that every operation takes O(log N ) time? No. It means that the amortized time is O(log N ). So a single operation might still take O( N ) time? Then whats the point? The bound is weaker. But the effect is the same: There are no bad input sequences. But if one node takes O( N ) time to access, we can keep accessing it for M times, cant we? Sure we can that only means that whenever a node is accessed, it must be moved . Idea : After a node is accessed, it is pushed to the root by a series of AVL tree rotations. k 5 F k 4 E k 3 D k 2 A k 1 C B Splay Trees k 5 F k 4 E k 3 D k 2 B A k 1 C k 5 F k 4 E k 2 B A k 1 k 3 D C k 5 F k 4 E k 2 B A k 1 k 3 D C k 4 E k 5 F k 2 B A k 1 k 3 D C Does NOT work! Splay Trees An even worse case: 1 2 2 1 3 3 2 1 Insert : 1, 2, 3, N 3 2 1 N Find : 1 3 2 1 N Find : 2 3 1 2 N Find : N 3 2 1 N T ( N ) = O ( N 2 ) 5...
View Full Document

This note was uploaded on 10/20/2011 for the course COMPUTER S 10586 taught by Professor Jilinwang during the Spring '09 term at Zhejiang University.

Page1 / 11

DS-chapter4(Splay Tree,B tree) - 4.5 Splay Trees Target :...

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

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