Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

countRepeats doesn't work as advertised #3

Open
rampion opened this issue Dec 10, 2015 · 1 comment
Open

countRepeats doesn't work as advertised #3

rampion opened this issue Dec 10, 2015 · 1 comment

Comments

@rampion
Copy link

rampion commented Dec 10, 2015

The docs for countRepeats say it should "[c]ount the number of times a sequence is repeated in the input sequence that was used to construct the suffix tree."

This works for some examples - the string "aba" should occur 4 times in "abab abac abad abaa"

λ SuffixTree.countRepeats "aba" $ SuffixTree.construct "abab abac abad abaa"
4

But not for others - the string "aba" should occur 4 times in "bababababab"

λ SuffixTree.countRepeats "aba" $ SuffixTree.construct "bababababab"
1
@xogcox
Copy link

xogcox commented Nov 26, 2020

This is likely related to issue #4. When constructing trees, it is necessary to terminate the input string with a character that does not occur at any other location in the string. Otherwise, the tree will not have the expected properties. Adding a $ character to the input string in the above example resolves the problem.

λ SuffixTree.countRepeats "aba" $ SuffixTree.construct "bababababab$"
4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants