These algorithms are much faster than the obvious straightforward implementation when the corpus contains long repeated substrings, though for many corpora, the complications required to avoid quadratic behavior are unnecessary.
far we have seen how to compute tf for a single n-gram, but how do we compute tf and df for all n-grams?