Upgrade to Pro — share decks privately, control downloads, hide ads and more …

In-Place BW Transform

kgoto
January 14, 2022

In-Place BW Transform

Chapter96 in the book 125 problems in Text Algorithms.

kgoto

January 14, 2022
Tweet

More Decks by kgoto

Other Decks in Research

Transcript

  1. In-Place BW Transform
    Chapter 96 in 125 problems book.
    Speaker: @kgoto
    Book Reading Seminar #15, January 14, 2022
    1
    1

    View full-size slide

  2. We call BW-string of
    We call BW-character of
    is 0-indexed
    BW Transform
    The Burrows-Wheeler transform of length- string is the word composed
    of the last letters of the sorted conjugates of .
    BW(x) n x
    x
    BW(x) x
    x[(n + i − 1) mod n] x[i..]
    x
    Today's topic
    Compute BW-string of in time in-place.
    x O(n )
    2
    2
    2

    View full-size slide

  3. Strategy
    Let , and transform to
    For to
    (loop-invariant) at the beginning,

    Transform to in time in-place
    z = x z = x z = BW(x)
    i = n − 1 0
    z = z

    =
    i+1 x[0..i]BW(x[i + 1..n − 1])
    z = z

    i+1 z

    i O(n)
    3
    3

    View full-size slide

  4. Observation
    is a permutation of
    For , BW-character of on is one of on
    BW-character of is
    BW(x[i..]) x[i..]
    j > i x[j..] x[i..] x[j..] x
    x[i..] #
    4
    4

    View full-size slide

  5. Transform to
    Let be the position of in
    swap and
    compute the position ( ) that
    will be inserted
    cyclic shift to the left by
    one
    z = z

    i+1
    z = z

    i
    p # z
    z[i] z[p]
    i + r #
    z[i..i + r]
    The remain task is to find the rank of .
    x

    i
    5
    5

    View full-size slide

  6. Finding rank of from one of is the common procedure of the
    backward search on BW-string.
    be the number of characters smaller than in
    It is the starting position of suffixes starting with in the suffix array
    be the numberof characters in
    It is the position of of suffixes starting with in the suffix array
    Here, is the rank of of suffixes for .
    x[i..] x[i + 1..]
    q x[i] x[i + 1..n − 1]
    x[i]
    t x[i] x[i + 1..p − 1]
    x[i..] x[i]
    r = q + t x

    i x

    j j ≥ i
    6
    6

    View full-size slide

  7. Compute form
    ( =bananna)
    ( =baannaa)
    ( =baanna#)
    z

    i
    z

    i+1
    z[p] ← x[i] z
    z[i..i + r − 1] ← z[i + 1..i + r] z
    z[i + r] ← # z
    7
    7

    View full-size slide

  8. Time and Space Complexities
    For each step, the alrotihm runs linear time and in-place.

    In total, the algorithm runs in time in-place
    O(n )
    2
    8
    8

    View full-size slide

  9. Reference
    The problem is discussed in the following paper.
    M. Crochemore, R. Grossi, J. Kärkkäinen and G. M. Landau. Computing
    the Burrows-Wheeler transform in place and in small space. J. Discrete
    Algorithms, 32:44–52, 2015.
    9
    9

    View full-size slide