labs-edaf30/lab2/edit_distance.h

18 lines
564 B
C
Raw Permalink Normal View History

2024-11-20 17:46:21 +01:00
#include <string>
/**
* @brief Computes the edit distance (Levenshtein distance) between two strings.
*
* The edit distance is defined as the minimum number of single-character edits
2024-11-21 08:49:45 +01:00
* (insertions, deletions, or substitutions) required to transform one string
* into the other.
2024-11-20 17:46:21 +01:00
*
2024-11-21 08:49:45 +01:00
* This implementation uses dynamic programming to compute the distance
* efficiently.
2024-11-20 17:46:21 +01:00
*
* @param s1 The first string.
* @param s2 The second string.
* @return The edit distance between the two strings.
*/
2024-11-21 08:49:45 +01:00
int edit_distance(const std::string &s1, const std::string &s2);