I have an aplication which performs some basic morphological analysis, and I am looking for an efficient means to count the number of change operations needed to transform a word into another, character by character changes.
Thanks in advance people.
The coin-change problem resembles the 0-1 Knapsack Problem in Dynamic Programming. It has two versions: Finding the minimum number of coins, of certain denominations, required to make a given sum. Finding the total number of possible ways a given sum can be made from a given set of coins.
The time complexity of the coin change problem is (in any case) (n*c), and the space complexity is (n*c) (n).
So, we create a minCoins array - minCoins[sum+1] where minCoins[i] represents minimum number of coins required to make change for amount = i. We build up the array in bottom up manner starting with minCoins[0]. The time complexity of the Dynamic Programming solution is O(n*sum). The space complexity is O(sum).
In Dynamic programming problems, Time Complexity is the number of unique states/subproblems * time taken per state. In this problem, for a given n, there are n unique states/subproblems. For convenience, each state is said to be solved in a constant time. Hence the time complexity is O(n * 1).
That sounds a lot like the Levenshtein Distance
The Levenshtein distance between two strings is defined as the minimum number of edits needed to transform one string into the other, with the allowable edit operations being insertion, deletion, or substitution of a single character
The article links to other comparison algorithms as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With