String Searching:The Position Heap
The Position Heap We now give a data structure that gives much simpler algorithms, at a cost of slightly in- creasing the worst-case time required for a query. The algorithms can easily be programmed by undergraduate data-structures students. The data structure is a trie, and has one node for each position in the text. The data structures and algorithms can be modified to give the same bounds for construction and searching, but this undermines the principal advantages, which are simplicity and low mem- ory requirements. The data structure is closely related to trees that are used for storing hash keys in [3]. Building the Position Heap Let a string be represented by a trie if it is the label of a path from the root in the trie. For analyzing the position heap us adopt the convention of indexing the characters of t in descending order, so t = t n t n − 1 ... t 1. In this case, we let t [ i : j ] denote t i t i − 1 ... t j . The algorithm for constructing the position heap c...