main page  —  COMP 526 Efficient Algorithms

Unit 6: Text Indexing – Searching whole genomes

This is an archived version of this module from Fall 2022.
Click here for the current iteration.

This unit covers data structures over static text that enable very efficient searching in the indexed text, including some more recent advances in this field. We cover

  • inverted indices
  • suffix trees
  • applications of suffix trees: string matching, longest repeated substrings, longest common substrings, k-mismatch matching
  • suffix arrays, LCP array
  • linear-time construction for suffix and LCP arrays

Learning outcomes

  1. Know and understand methods for text indexing: inverted indices, suffix trees, (enhanced) suffix arrays
  2. Know and understand generalized suffix trees
  3. Know properties, in particular performance characteristics, and limitations of the above data structures.
  4. Design (simple) algorithms based on suffix trees.
  5. Understand construction algorithms for suffix arrays and LCP arrays.

Material

  • slides
  • lecture notes

  • Video 6-1 · transcript (2022-11-09, 35:25): §6.1 Motivation, inverted indices, tries
    Chapters0:56 Learning Outcomes
    1:58 Text indexing
    5:17 Inverted indices
    26:38 Clicker Question
    28:13 Compact tries
    34:15 Tries as inverted index
  • Video 6-2 · transcript (2022-11-09, 26:03): §6.2 Suffix trees
    Chapters0:21 Suffix trees- A 'magic' data structure
    8:47 Suffix trees - Construction
    21:29 Clicker Question
  • Video 6-3 · transcript (2022-11-09, 27:56): §6.3 Applications of suffix trees
    Chapters0:18 Applications of suffix trees
    9:36 Application 1: Text Indexing/String Matching
    15:05 Longest repeated substring
    22:00 Generalized suffix trees
    23:48 Clicker Question
    24:29 Longest common substring ► With that new idea, we can find longest common substrings
    24:39 Longest common substring - Example
    27:05 Application 3: Longest common substring
  • Video 6-5 · transcript (2022-11-21, 30:14): §6.4 Longest common extensions
    Chapters0:16 Longest Common Extensions
    7:12 Efficient LCA
    15:51 Clicker Question
    18:52 Kangaroo Algorithm for approximate matching
    23:28 Matching with wildcards
    26:03 Suffix trees - Discussion
  • Video 6-6 · transcript (2022-11-21, 7:28): §6.5 Suffix arrays (part 1)
  • Video 6-6 · transcript (2022-11-23, 25:56): §6.5 Suffix arrays (part 2)
    Chapters0:02 Putting suffix trees on a diet
    4:06 Clicker Question
    7:41 Suffix arrays - Construction
    11:05 Fat-pivot radix quicksort - Example
  • Video 6-7 · transcript (2022-11-23, 24:32): §6.6 Linear-time suffix sorting – Overview
    Chapters0:54 Inverse suffix array: going left & right
    4:31 Clicker Question
    8:01 Linear-time suffix sorting
    12:11 DC3/ Skew algorithm - Step 2: Inducing ranks
    14:33 DC3/ Skew algorithm - Inducing ranks example
    18:29 DC3/Skew algorithm - Step 3: Merging
    21:37 DC3/ Skew algorithm - Step 3: Merging
  • Video 6-8 · transcript (2022-11-23, 10:15): §6.7 Linear-time suffix sorting – DC3 recursion
    Chapters0:16 DC3/ Skew algorithm - Fix recursive call
    3:43 DC3/Skew algorithm - Fix alphabet explosion
    6:15 DC3/Skew algorithm - Step 3. Example
    8:49 Suffix array - Discussion
  • Video 6-9 · transcript (2022-11-23, 28:58): §6.8 LCP arrays
    Chapters0:23 Clicker Question
    3:05 String depths of internal nodes
    8:26 LCP array and internal nodes
    14:20 LCP array construction
    17:32 Kasai's algorithm - Example
    23:20 Kasai's algorithm - Code

Further reading and sources

There is no textbook that covers all topics, but parts can be found in the following sources, all of which cover much more than the topics I selected.

Tries: These are notoriously treated only in passing in most algorithms and data structures textbooks, and there are various little differences in the details. Apart from the fact that they do not insist on prefix-free keys, I find the most helpful treatment of tries is given by Sedgewick and Wayne:

Suffix trees:

Suffix arrays have not yet found widespread inclusion in standard textbooks; my way of presenting it is mostly my own, but took inspiration from

Suffix arrays and LCP arrays are also discussed (in slightly different form) in


Unit 5  ⋅  Syllabus  ⋅  Unit 7