Download presentation
Presentation is loading. Please wait.
Published bySharyl Bradley Modified over 9 years ago
1
A Logarithmic Randomly Accessible Data Structure Tom Morgan TJHSST Computer Systems Lab 2006-2007
2
Purpose To create a data structure with: O(log(N)) insertion O(log(N)) deletion O(log(N)) random access To implement the data structure and empirically test the general case run time To prove the data structure's worst case run time
3
Background Dynamic Arrays O(N) insertion O(N) deletion O(1) random access Red-Black Trees O(log(N)) insertion O(log(N)) deletion not randomly accessible Splay Trees amortized O(log(N)) insertion amortized O(log(N)) deletion not randomly accessible
4
The Basic Algorithm Similar to binary search tree Places values only at the leaves Each node keeps track of the number of leaves below it O(log(N)) on all operations in a random case, but not a sequential one Balancing is underway
5
An Example Tree
6
Balancing Techniques When performing any operation, if not balanced: Shift one element from bigger side to smaller side Shift half of bigger side to smaller side Find best cutoff point along nearest side to smaller side (if right is bigger, the left part of it) and shift over corresponding sub-tree
7
Red Black Tree Each node is either red or black The path from the root to each leaf contains the same number of black nodes A red node may not have a red parent Absurd amount of cases
8
Splay Tree Standard binary search tree but for splay function Splay function is called everytime a node is accessed Splay function rotates accessed node up to the root position
9
Testing Data structure implemented in Java as a class Test various operations and their runtime using a separate testing program in Java, which uses the class Tester allows for both random and ordered insertion and deletion Balanced tree compared to TreeSet and ArrayList
10
Results: Pre-Red Black Tree A tree that allows for insertion, deletion and random access All operations are logarithmic on the random case Three separate balancing techniques which vary in terms of effectiveness of balancing and time taken by the balancing None of the balancing techniques are perfect as of now
11
Results: Red Black Tree Started making randomly accessible but quickly encountered errors Insertion works fine but deletion appears to throw off properties Have added numerous testing and analysis functions to no avail Work suspended in favor of Splay Tree
12
Results: Splay Tree The Splay Tree is fully functional Has complete random access functionality Works with Java's templates Made compliant with Collection and AbstractList Added depth-first search iterator, allowing O(N) access of all elements in sequence
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.