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

Classic-modern interpretations #33

Open
ppKrauss opened this issue Feb 4, 2018 · 0 comments
Open

Classic-modern interpretations #33

ppKrauss opened this issue Feb 4, 2018 · 0 comments

Comments

@ppKrauss
Copy link

ppKrauss commented Feb 4, 2018

Checking the isPalindrome... The classic algorithms are expressed as an "character-by-character algorithm", and is fine. Is oriented to a low-level view of algoritms and data-structures.

Another classic manner to view pattern-recognition algoritms in strings, is to express it by regular expression

  • isPalindrome() by "anchored recursive" regular expression ^((.)(?:(?1)|.?)\2)$

  • containsPalindrone() by recursive regular expression, supposing only letters (\w)(?:(?R)|\w?)\1

It is a good view from a first abstraction layer of strings... And is also classic.


The best layer for an algorithm perhaps is where the simplest and faster algorithm is expressed. It is also "classic". In the isPalindrome() an intermediary layer of abstraction, the ideal to express the same algorithm, is by use the string.reverse() method to compare strings.

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

1 participant