140 likes | 299 Views
Engineering a Sorted List Data Structure for 32 Bit Keys. Roman Dementiev Lutz Kettner Jens Mehnert Peter Sanders MPI f ür Informatik, Saarbrücken. Introduction. The power of integer keys helps in Sorting (radix MSB,LSB) Priority queues (radix heaps) Static search trees
E N D
Engineering a Sorted List Data Structure for 32 Bit Keys Roman Dementiev Lutz Kettner Jens Mehnert Peter Sanders MPI für Informatik, Saarbrücken
Introduction • The power of integer keys helps in • Sorting (radix MSB,LSB) • Priority queues (radix heaps) • Static search trees • Dictionaries (hash tables) • Faster both in theory and practice • What about dynamic search data structures? R. Dementiev et al.: A Sorted List Data Structure for 32 Bit Keys (ALENEX'04)
Motivation • van Emde Boas (vEB) search trees [van Emde Boas77,MehlhornNaeher90]: • Small K, large n→ vEB are faster ? • NO, their direct implementations are 2-8 times slower than comp. based trees [Wenzel92,here] • Here: a tuned vEB data structure that outperforms comp. based implementations n – number of elements K – bit width of keys c – size of the output R. Dementiev et al.: A Sorted List Data Structure for 32 Bit Keys (ALENEX'04)
Direct vEB Implementation • vEB tree maintains set • Recursive definition: • |M|=1 or K=1: store directly, • otherwise let K’ = K/2: store minM,maxM, • top: store (top recursion) • boti: store (bottom recursion) use hash table K’ bit vEB top hash table K’ bit vEB boti R. Dementiev et al.: A Sorted List Data Structure for 32 Bit Keys (ALENEX'04)
0 63 … 31 32 63 0 4095 … … … … 31 32 0 63 65535 … … … … Improvement 1 • Replace top data structure with a bit pattern hierarchy K’ bit vEB top hash table K’ bit vEB boti R. Dementiev et al.: A Sorted List Data Structure for 32 Bit Keys (ALENEX'04)
0 63 … 31 32 63 0 4095 … … … … 31 32 0 63 65535 … … … … Level 1 – root Bits 31-16 Level 2 Bits 15-8 K’ bit vEB boti … … … single elements Level 2 Bits 15-8 … … … … … … … … … hash table hash table hash table Level 3 Bits 7-0 Improvement 2 • Break recursion when K=8 3 levels max. hash table R. Dementiev et al.: A Sorted List Data Structure for 32 Bit Keys (ALENEX'04)
Level 1 – root Bits 31-16 0 65535 array hash table … 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Level 2 Bits 15-8 … … … single elements Level 2 Bits 15-8 … … … … … … … … … hash table hash table hash table Level 3 Bits 7-0 Improvement 3 0 63 … • Replace root hash table with an array 31 32 63 0 4095 … … … … 31 32 0 63 65535 … … … … R. Dementiev et al.: A Sorted List Data Structure for 32 Bit Keys (ALENEX'04)
0 65535 array … 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 … … … … … … … … … … … … hash table hash table hash table Range Query Support 0 63 … • Link elements 31 32 63 0 4095 … … … … 31 32 0 63 65535 … … … … Level 1 – root Bits 31-16 Level 2 Bits 15-8 Level 2 Bits 15-8 Level 3 Bits 7-0 R. Dementiev et al.: A Sorted List Data Structure for 32 Bit Keys (ALENEX'04)
Example: Locate Operation • return handle of • Function locate(y:N):ElementHandle ify > maxMthenreturn // no larger element i := y[16..31] // index into root table top iftop[i]=nullory>maxMithenreturnminMtop.locate(i) // look in the next L2 table ifMi={x} thenreturnx // single element case j := y[8..15] // key for L2 table at Mi ifri[j]=nullory > maxMijthenreturnminMi,top(i).locate(j) // look in the next L3 table ifMij={x} thenreturn x // single element case returnrij[topij.locate(y[0..7])] // L3 table access • At most 9 comparisons for any input sizes R. Dementiev et al.: A Sorted List Data Structure for 32 Bit Keys (ALENEX'04)
Locate Performance R. Dementiev et al.: A Sorted List Data Structure for 32 Bit Keys (ALENEX'04)
Construction R. Dementiev et al.: A Sorted List Data Structure for 32 Bit Keys (ALENEX'04)
Deletion R. Dementiev et al.: A Sorted List Data Structure for 32 Bit Keys (ALENEX'04)
Hard Inputs R. Dementiev et al.: A Sorted List Data Structure for 32 Bit Keys (ALENEX'04)
Conclusions and Future Work • Integer search trees can outperform comp. based search data struct. • Future work: • Support multi-set functionality • Other key lengths (up to 38 bits) • Reduce space consumption • Find real inputs • Port it to the LEDA library R. Dementiev et al.: A Sorted List Data Structure for 32 Bit Keys (ALENEX'04)