Created
August 10, 2015 02:33
-
-
Save stephenhandley/16941506cf6d2c5732b7 to your computer and use it in GitHub Desktop.
Potential bug with FrequentWordsWithMismatches pseudocode in "Finding Hidden Messages in DNA" book
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FrequentWordsWithMismatches(Text, k, d) | |
| FrequentPatterns ← an empty set | |
| Neighborhoods ← an empty list | |
| for i ← 0 to |Text| − k | |
| add Neighbors(Text(i, k), d) to Neighborhoods | |
| form an array NeighborhoodArray holding all strings in Neighborhoods | |
| for i ← 0 to |Neighborhoods| − 1 | |
| Pattern ← NeighborhoodArray(i) | |
| Index(i) ← PatternToNumber(Pattern) | |
| Count(i) ← 1 | |
| SortedIndex ← Sort(Index) | |
| for i ← 0 to |Neighborhoods| − 1 | |
| if SortedIndex(i) = SortedIndex(i + 1) | |
| Count(i + 1) ← Count(i) + 1 | |
| maxCount ← maximum value in array Count | |
| for i ← 0 to |Neighborhoods| − 1 | |
| if Count(i) = maxCount | |
| Pattern ← NumberToPattern(SortedIndex(i), k) | |
| add Pattern to FrequentPatterns | |
| return FrequentPatterns |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FrequentWordsWithMismatches(Text, k, d) | |
| FrequentPatterns ← an empty set | |
| Neighborhoods ← an empty list | |
| for i ← 0 to |Text| − k | |
| add Neighbors(Text(i, k), d) to Neighborhoods | |
| form an array NeighborhoodArray holding all strings in Neighborhoods | |
| for i ← 0 to |NeighborhoodArray| − 1 | |
| Pattern ← NeighborhoodArray(i) | |
| Index(i) ← PatternToNumber(Pattern) | |
| Count(i) ← 1 | |
| SortedIndex ← Sort(Index) | |
| for i ← 0 to |NeighborhoodArray| − 1 | |
| if SortedIndex(i) = SortedIndex(i + 1) | |
| Count(i + 1) ← Count(i) + 1 | |
| maxCount ← maximum value in array Count | |
| for i ← 0 to |NeighborhoodArray| − 1 | |
| if Count(i) = maxCount | |
| Pattern ← NumberToPattern(SortedIndex(i), k) | |
| add Pattern to FrequentPatterns | |
| return FrequentPatterns |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you so much!