Exotic Data StructuresLet's consider these conceputal data structures:
Nothing out of the ordinary, right ? note: No persistence here. Full persistence in O(1) space is hard[1,2]. Essentially all 'persistent' datastructures used in practice are broken (leaking more than linear space). 1. Compact dynamic array (compactarrays)An indexable deque which is optimal in space and time [3]. This is simply a O(sqrtN) array of O(sqrtN) subarrays. Two lists of arrays are maintained, small and big (twice bigger) Also, pointers to head/tail indexes, and the big/small separation are maintained. Conceptually, the virtual array is the concatenation of all small subarrays followed by the big subarrays, and indexed between head/tail. All operations are straightforward. In order to maintain the global invariants, small subarrays are sometimes merged into big arrays, or big arrays are split into small arrays (this happens at the boundary between the two lists). when one of both lists is empty, lists are swapped (big arrays become small and viceversa) Asymptotic complexity:
Variant: Compact integer arraysThis is implemented by growing the integer range of subarrays dynamically when an update overflows. It makes updates O(sqrtN) worst case (O(1) amortized if O(N) numbers take O(lgM) bits). Asymptotic complexity:
2. Monlithic and Succinct lists (monolithiclists, succinctlists)Monolithic listsMonolithic lists are lists stored without any managed pointers, in a flat array. Each node in the list is identified by a number in [1..N]. 0 is the head and 1 the tail. Insertion allocates nodes, removal reclaims them. Because the links are xorcoded, two consecutive nodes are needed to form a cursor. given a cursor, you can query the list for the next or previous element. To store values at each node, you can simply use node identifiers to index a [1..N] array. This makes cache behavior even worse, but it doesn't matter much, as indexing lists is slow anyway. note: unrolled lists are isomorphic to lists of arrays. they offer no improvement. Asymptotic complexity:
Succinct listsA succinct data structure has space usage close to the information theoretic lower bound. In essence, a list is isomorphic to an Hamiltonian cycle in a complete graph of n nodes. There are O(N!) such cycles. Thus at least lg(N!) + o(N) bits are needed to encode a list. This gives us NlgN + o(N) as a lower bound. Succinct lists achieve this lower bound (tightly) and can still operate efficiently. To achieve this, succinct lists are simply monolithic lists stored in the previously defined compact integer arrays. Asymptotic complexity:
3. Split Hashtables and dary cuckoo hashing (splithashtables, dcuckoo)Split hashtablesSplit hashtables are a variation of cuckoo hashing, that doesn't move anything around. In essence, this structure is a pair of arrays of lists of key/value pairs. Lookup is done by splitting the hash of the key in two, using this pair to index the arrays, and then search each list for the key. The twist is that insertion is always in the shortest list. Surprisingly, that gives us an informationtheoretic advantage that reduces the expected worst case list length significantly [4]. This works so well that it's a waste of time to make any effort to move elements around (as in cuckoo hashing). Also, the structure can operate efficiently an load. Of course, to get the good performance, some tweaks can make the difference. For space usage: Single element lists are inlined into the arrays (there are two words to accomodate for a key/value pair). The lists themselves are stored as arrays (with the usual amortized growth). This ensures that the data structure stays efficient in all usage cases: sparse entries do not waste too much space, and long lists converge to optimal density. For speed: The most critical operation for an unordered set is to answer queries. This is divided into five stages in split hashtables:
Insertions and removal are performed with a variant of query that returns the key/value pair by reference. Removals query for the key and and replace the key/value pair with ((free)) f. (compaction is done only on demand) Insertions query for a ((free)) key and store the key/value pair over it. If the query fails, the appropriate list is copied into a large array completed with ((free)) f key/value pairs. A load of 50 Asymptotic complexity:
dary cuckoo hashing[ for O(1) worst case lookup maps with very high density (90 4. Rotated lists (rotatedlists)[ arrays with good random insertion/removal and lookup speed ] 5. B+ trees, Adaptive packed memory arrays (btrees)B+ trees[ boring ordered maps. we can't beat lgN with comparison order. very fast insertion/removal/balancing, very compact. ] Adaptive pack memory arrays[ ordered map in a flat array with some bubbles. funny but not really competitive. B+ trees are boring ] 6. Speculative hollow arrays (hollowarrays)[ sparse array optimized for maximum speed within a space budget, with speculative relayout to match opportunities in density ] 7. van Emde Boas trees, yfast trees, approximate ordered sets (yfasttrees)van Emde Boas treess[ ordered map over a finite universe. lglgN search ] yfast trees[ space efficient van Emde Boas trees ] approximate ordered sets[ O(1) ordered maps with a weak ordering on keys ] References[1] J. R. Driscoll, N. Sarnak, D. D. Sleator, R. E. Tarjan. Making data structures persistent. Journal of Computer and System Sciences. Volume 38, Issue 1, February 1989. http://www.cs.cmu.edu/~sleator/papers/makingdatastructurespersistent.pdf [2] P. F. Dietz . Fully Persistent Arrays (Extended Array). Lecture Notes in Computer Science, Volume 382, 1989 https://gummo.lib.rochester.edu/retrieve/14496/tr%23290.pdf [3] A. Brodnik, S. Carlsson, E. D. Demaine, J. I. Munro, and R. Sedgewick. Resizable arrays in optimal time and space. Technical Report CS9909, U. Waterloo, 1999. http://www.cs.uwaterloo.ca/~imunro/resize.ps [4] M. Mitzenmacher. The power of two choices in randomized load balancing. Parallel and Distributed Systems, IEEE Transactions on. Volume 12, Issue 10, Oct 2001 http://www.eecs.harvard.edu/~michaelm/postscripts/mythesis.pdf This revision created on Wed, 10 Dec 2008 04:28:27 by prunedtree 

All content is © 20082010 by its respective authors. By adding content to this wiki, you agree to release it under the BSD license. 