Skip to content

Instantly share code, notes, and snippets.

@Teino1978-Corp
Forked from chitreshkakwani/amt.cpp
Created October 28, 2015 15:47
Show Gist options
  • Save Teino1978-Corp/32176bbaa956d87dfdc6 to your computer and use it in GitHub Desktop.
Save Teino1978-Corp/32176bbaa956d87dfdc6 to your computer and use it in GitHub Desktop.
Array Mapped Trie design
// Store all the levels in separate tables
/* Level 1 - 0000100001 | 0
Level 2 - 0000101100 | 2
0110000000 | 0
Level 3 - 0000100010 | 7
0000100010 | 5
0000100010 | 3
0000100000 | 2
0000101010 | 0
*/
/* Insertion
Each time a bit is written, update the count of bits in the bit count field of all the bit arrays above
that bit array in that table
*/
/* Reading
1. Read all the data in one go. Separate the first byte array which is of fixed size.
2. Obtain the bit count in that bit array and read the next byte array table accordingly and so on.
*/
/* Traversing
1. Go through the bit array. For each set bit, obtain its index in the bit array and corresponding character.
One of these character's children will be requested in the next step. Store the indixes of these characters
in a hash table for fast lookup.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment