Coder Social home page Coder Social logo

Comments (3)

nictru avatar nictru commented on August 25, 2024

Is it possible that because of the strong shifting rule that is additionally implemented when using the z-boxes, the shifts can be larger while still being safe?
In other words: Do these shift tables even have to be identical?

However, with a certain example (pattern=bbababbaba, text=bbabbababbaba) i managed to enter an infinite loop, which should also be investigated

from algobio.

Scroogeee avatar Scroogeee commented on August 25, 2024

The script says that border'[j] = j − S[j] for S being the shift table computed by the z-box-method.
Should the method return S or border'?

from algobio.

nictru avatar nictru commented on August 25, 2024

So apparently you were right with what the hint to S and border'. The original kmp border table calculation calculates a border table, not a shift table - so within the KMP algorithm, we use j-border[j] in order to get back to the shifts. When using z-boxes, we the script shows us how to calculate shift tables, which we then have to convert to border tables manually in order to be able to use them within the same KMP algorithm.

Alternatively, we could have altered the KMP algorithm so that the shift table can be used natively. This way we would not have had to convert the shift table to a border table and then (within KMP) back again. Since this would result in more code, I did not follow this path.

Note, that I also implemented a version of the border table calculation using z-boxes which is based on the mathematical definition instead of the pseudo code. This was helpfull for finding minor flaws in the code.

from algobio.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.