p-fast trie, but smaller

Aug. 6th, 2025 06:21 pm[personal profile] fanf
fanf: (Default)

https://dotat.at/@/2025-08-06-p-fast-trie.html

Previously, I wrote some sketchy ideas for what I call a p-fast trie, which is basically a wide fan-out variant of an x-fast trie. It allows you to find the longest matching prefix or nearest predecessor or successor of a query string in a set of names in O(log k) time, where k is the key length.

My initial sketch was more complicated and greedy for space than necessary, so here's a simplified revision.

Read more... )

fanf: (Default)

https://dotat.at/@/2025-08-04-p-fast-trie.html

Here's a sketch of an idea that might or might not be a good idea. Dunno if it's similar to something already described in the literature -- if you know of something, please let me know via the links in the footer!

The gist is to throw away the tree and interior pointers from a qp-trie. Instead, the p-fast trie is stored using a hash map organized into stratified levels, where each level corresponds to a prefix of the key.

Exact-match lookups are normal O(1) hash map lookups. Predecessor / successor searches use binary chop on the length of the key. Where a qp-trie search is O(k), where k is the length of the key, a p-fast trie search is O(log k).

This smaller O(log k) bound is why I call it a "p-fast trie" by analogy with the x-fast trie, which has O(log log N) query time. (The "p" is for popcount.) I'm not sure if this asymptotic improvement is likely to be effective in practice; see my thoughts towards the end of this note.

Read more... )

December 2008

S M T W T F S
 123456
78910111213
14151617181920
21222324 252627
28293031   

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Aug. 9th, 2025 07:17 pm
Powered by Dreamwidth Studios