Comments (3)
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.
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.
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from algobio.