ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
TwoLevelDictionary.h File Reference

The two-level dictionary of strings, beyond the book: the lower level is the front coding of the sorted strings with anchors [see FrontCodedDictionary in FrontCoding.h], the strings that are stored whole, either one every \( b \) (the bucketing) or as the locality-preserving coding decides, and the upper level a Patricia trie [see PatriciaTrie.h] on the anchors alone. More...

#include "ADS/Contract.h"
#include "ADS/dictionary/PatriciaTrie.h"
#include "ADS/string/FrontCoding.h"
#include <cstddef>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
#include "ADS/dictionary/impl/TwoLevelDictionary.tpp"

Go to the source code of this file.

Classes

class  ADS::TwoLevelDictionary
 a Patricia trie on the anchors of a front-coded dictionary More...

Namespaces

namespace  ADS

Detailed description

The two-level dictionary of strings, beyond the book: the lower level is the front coding of the sorted strings with anchors [see FrontCodedDictionary in FrontCoding.h], the strings that are stored whole, either one every \( b \) (the bucketing) or as the locality-preserving coding decides, and the upper level a Patricia trie [see PatriciaTrie.h] on the anchors alone.

A search by prefix is the blind search of the pattern among the anchors, which reads one anchor, and the scan of the one bucket where the pattern falls, decoded on the fly: with the trie in memory and the coding on disk, \( O( p / B + | s | / B ) \) transfers of blocks for a pattern of \( p \) characters, \( s \) being the string read by the blind search, plus the bucket (chapter 9 of Ferragina), in \( O( n_a ) \) words of memory for \( n_a \) anchors and \( ( 1 + \epsilon ) \mathrm{FC}( D ) \) characters on disk with the locality-preserving coding. The upper level is independent of the lower one: a binary search on the anchors [see FrontCodedDictionary::lexicographicPosition()] costs \( O( ( p / B ) \log n_a ) \) transfers instead. When even the trie does not fit in memory, the string B-tree of Ferragina and Grossi splits it into Patricia tries of a block each, linked as a B-tree, for \( O( ( p + N_{occ} ) / B + \log_B n ) \) transfers.

The contracts [see Contract.h]: those of FrontCodedDictionary and of PatriciaTrie; each position \( r \) is such that the strings before \( r \) are smaller than the pattern (or than \( P\# \)) and those from \( r \) on are not, a postcondition. The functions are defined in TwoLevelDictionary.tpp.

See also
P. Ferragina, Pearls of Algorithm Engineering, Cambridge University Press, 2023, chapter 9, Searching Strings by Prefix, doi:10.1017/9781009128933
P. Ferragina, R. Grossi, The string B-tree: a new data structure for string search in external memory and its applications, Journal of the ACM 46(2), 236-280, 1999, doi:10.1145/301970.301973
M. A. Bender, M. Farach-Colton, B. C. Kuszmaul, Cache-oblivious string B-trees, Proceedings of PODS 2006, 233-242, 2006, doi:10.1145/1142351.1142385
D. R. Morrison, PATRICIA: practical algorithm to retrieve information coded in alphanumeric, Journal of the ACM 15(4), 514-534, 1968, doi:10.1145/321479.321481
Author
Donato Meoli
Dipartimento di Informatica
Università di Pisa