110 likes | 123 Views
A Logarithmic Randomly Accessible Data Structure. Tom Morgan TJHSST Computer Systems Lab 2006-2007. 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
E N D
A Logarithmic Randomly Accessible Data Structure Tom Morgan TJHSST Computer Systems Lab 2006-2007
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
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
The Algorithm Pre-Red Black Tree • 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
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
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 • /cry
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 • Red Black Tree compared to TreeSet
Results So Far 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
Results So Far Red Black Tree • It works! • I'm just starting the work on making it randomly accessible • Much to go on this front
Current/Future Work • Make RBT randomly accessible • Later work perhaps on developing parallel processing capabilities