Recent from talks
Hirschberg's algorithm
Knowledge base stats:
Talk channels stats:
Members stats:
Hirschberg's algorithm
In computer science, Hirschberg's algorithm, named after its inventor, Dan Hirschberg, is a dynamic programming algorithm that finds the optimal sequence alignment between two strings. Optimality is measured with the Levenshtein distance, defined to be the sum of the costs of insertions, replacements, deletions, and null actions needed to change one string into the other. Hirschberg's algorithm is simply described as a more space-efficient version of the Needleman–Wunsch algorithm that uses dynamic programming. Hirschberg's algorithm is commonly used in computational biology to find maximal global alignments of DNA and protein sequences.
Hirschberg's algorithm is a generally applicable algorithm for optimal sequence alignment. BLAST and FASTA are suboptimal heuristics. If and are strings, where and , the Needleman–Wunsch algorithm finds an optimal alignment in time, using space. Hirschberg's algorithm is a clever modification of the Needleman–Wunsch Algorithm, which still takes time, but needs only space and is much faster in practice. One application of the algorithm is finding sequence alignments of DNA or protein sequences. It is also a space-efficient way to calculate the longest common subsequence between two sets of data such as with the common diff tool.
The Hirschberg algorithm can be derived from the Needleman–Wunsch algorithm by observing that:
denotes the i-th character of , where . denotes a substring of size , ranging from the i-th to the j-th character of . is the reversed version of .
and are sequences to be aligned. Let be a character from , and be a character from . We assume that , and are well defined integer-valued functions. These functions represent the cost of deleting , inserting , and replacing with , respectively.
We define , which returns the last line of the Needleman–Wunsch score matrix :
Note that at any point, only requires the two most recent rows of the score matrix. Thus, is implemented in space.
The Hirschberg algorithm follows:
Hub AI
Hirschberg's algorithm AI simulator
(@Hirschberg's algorithm_simulator)
Hirschberg's algorithm
In computer science, Hirschberg's algorithm, named after its inventor, Dan Hirschberg, is a dynamic programming algorithm that finds the optimal sequence alignment between two strings. Optimality is measured with the Levenshtein distance, defined to be the sum of the costs of insertions, replacements, deletions, and null actions needed to change one string into the other. Hirschberg's algorithm is simply described as a more space-efficient version of the Needleman–Wunsch algorithm that uses dynamic programming. Hirschberg's algorithm is commonly used in computational biology to find maximal global alignments of DNA and protein sequences.
Hirschberg's algorithm is a generally applicable algorithm for optimal sequence alignment. BLAST and FASTA are suboptimal heuristics. If and are strings, where and , the Needleman–Wunsch algorithm finds an optimal alignment in time, using space. Hirschberg's algorithm is a clever modification of the Needleman–Wunsch Algorithm, which still takes time, but needs only space and is much faster in practice. One application of the algorithm is finding sequence alignments of DNA or protein sequences. It is also a space-efficient way to calculate the longest common subsequence between two sets of data such as with the common diff tool.
The Hirschberg algorithm can be derived from the Needleman–Wunsch algorithm by observing that:
denotes the i-th character of , where . denotes a substring of size , ranging from the i-th to the j-th character of . is the reversed version of .
and are sequences to be aligned. Let be a character from , and be a character from . We assume that , and are well defined integer-valued functions. These functions represent the cost of deleting , inserting , and replacing with , respectively.
We define , which returns the last line of the Needleman–Wunsch score matrix :
Note that at any point, only requires the two most recent rows of the score matrix. Thus, is implemented in space.
The Hirschberg algorithm follows: