1 / 12

A Logarithmic Randomly Accessible Data Structure

This project aims to create a data structure with O(log(N)) insertion, deletion, and random access. The implementation and empirical testing of the data structure's general case runtime will be conducted.

louiseb
Download Presentation

A Logarithmic Randomly Accessible Data Structure

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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

More Related