Add Edit Distance Algorithm to Dynamic Programming #82
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.
Add Edit Distance Algorithm to Dynamic Programming
This pull request adds the implementation of the Edit Distance algorithm to the Dynamic Programming (DP) section of the algorithms repository.
Description
The Edit Distance algorithm calculates the minimum number of operations (insertion, deletion, substitution) required to transform one string into another. This is a classic dynamic programming problem with applications in spell checking, DNA sequence alignment, and natural language processing.
Implementation Details
dp/edit_distance.py
The algorithm uses a 2D DP table to store intermediate results, with each cell representing the minimum edit distance for substrings of the input strings.
Test Cases
A comprehensive set of unit tests has been added in
dp/test_edit_distance.py
, covering:All tests pass successfully, ensuring the correctness of the implementation.
Integration with Existing Codebase
This new algorithm complements the existing DP algorithms in the repository, providing a solution to a fundamental string manipulation problem. It follows the coding style and structure of other algorithms in the project.
Usage Example
This PR is ready for review and integration into the main branch.
This Devin run was requested by Federico.