Stale tape detection implementation #55
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is an implementation for issue #26. While I think the
view
portion of this code is satisfactory, I did not follow the recommendation mentioned in the issue.I will expound on the implementation here (this can be copypasted into the issue thread too):
Array Character
representation of tapes. Now consider the two operationson individual tapes,
Add
a character, orDelete
a character (from the right):defined in the Sigma of the machine. Constant time!
For simplicity, we assume a constant cost of conversion between intermediary data structures.
The algorithm then becomes: For each character in the array, check if there exists its transition
in Sigma. Construction of Sigma is linear w.r.t the number of transition edges in the machine.
The runtime for checking one tape is then O(#transitions + length(tape)).
onEnter
iscalled) will then be O(#tapes *(#transitions + length(tape))).
Storing as CharacterID will save time on checking, but the argument is that #tapes and tape length is small anyway. This part of the code should then be under consideration when we look to optimize.