Skip to content
Embercode
✕
StringsQuick quiz

Suffix structures

8 questions. Covers Suffix automaton (overview).

Questions 1 to 5 of 8

  1. 1. The lesson's suffix array code sorts suffixes with prefix doubling. What are its time and memory costs?
  2. 2. In Kasai's method for the LCP array, why is the total work O(n)?
  3. 3. An AI defines lcp[r] as the LCP of sa[r] and sa[r+1], and answers queries with the minimum of lcp[l+1..r]. What is wrong?
  4. 4. The text is banana. Its suffix array is 5 3 1 0 4 2. What is the LCP of the suffixes at positions 3 (ana) and 1 (anana)?

    Type a number.

  5. 5. Put these steps of one suffix automaton extend (adding a letter c) in order.

    Use the arrows to put the steps in order.

    1. 1.Walk suffix links from last, adding a transition by c to each state that has none
    2. 2.Set the links of q and cur to the clone, or to 0 when the walk found no state
    3. 3.Set last to cur
    4. 4.Create the new state cur with len equal to len(last) + 1
    5. 5.If the walk meets a state p whose transition by c leads to q with len(p) + 1 < len(q), clone q and redirect the transitions that point to q

4 question(s) left on this page.

Typed answers ignore extra spaces and, for most questions, capital letters.