Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Counting change operations c#

Tags:

c#

.net

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.

like image 654
Matt Avatar asked Jul 13 '10 10:07

Matt


People also ask

Is coin change knapsack problem?

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.

What is the time complexity of coin change problem?

The time complexity of the coin change problem is (in any case) (n*c), and the space complexity is (n*c) (n).

What is the formula for calculating the minimum number of coins?

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).

What is the time complexity of making change using Dynamic Programming?

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).


1 Answers

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.

like image 153
stuartd Avatar answered Sep 29 '22 21:09

stuartd