User talk:Ledrug

Revision as of 02:01, 5 July 2011 by rosettacode>Mwn3d (Undo revision 112704 by Hy220 (talk) Vandalism)

Levenshtein distance C code

I Just noticed that you posted a recursive C solution for Levenshtein distance. Could you maybe explain (here or in/near the example) what the variables mean in that solution? I tried to come up with a recursive solution in Java myself, but it didn't work out so well. If at all possible could you maybe just give some pseudocode for the recursive algorithm? --Mwn3d 20:25, 20 June 2011 (UTC)

The recursion function has 4 parameters: s, string 1; ls: length of s; t: string 2; lt length of t. Basically, <lang>function levenschtein(s, t)
   if length(s) = 0: return length(t)
   if length(t) = 0: return length(s)
   if s[0] = t[0]  : return levelschtein(s[1 .. end], t[1 .. end])
   len1 := levelschtein(s, t[1 .. end]) + 1
   len2 := levelschtein(s[1 .. end], t) + 1
   len3 := levelschtein(s[1 .. end], t[1 .. end]) + 1
   return min(len1, len2, len3)

</lang>where s[0] meaning first char in string s; s[1 .. end] meaning s without first char. (heh this reads just like the C code. I suck at pseudo code.) --Ledrug 20:39, 20 June 2011 (UTC)

Oh duh. C strings. Forgot about passing around lengths separately. So this says if either string is empty, return the length of the other string (because you just insert or delete all of the other string). If the first chars are the same, nothing needs to happen so just ignore them. Otherwise try deleting one char (len1), inserting one char (len2), or essentially making the first chars the same (as len3 but count the move this time), and return the minimum distance from those. OK I think I got it. Thanks for that. It's really close to what I was thinking of when I tried to do it, but this makes much more sense. I'll try to translate it soon. --Mwn3d 20:50, 20 June 2011 (UTC)
Any chance you might add this to the tasks talk page? I'll be adding a (memoized) version of this in the Python section. Thanks. --Paddy3118 21:45, 20 June 2011 (UTC)
But the wikipedia solution is the memoized version, though? --Ledrug 22:26, 20 June 2011 (UTC)
Hi, there are no recursive calls here. --Paddy3118 05:15, 21 June 2011 (UTC)
Yeah I know, I meant if you memoize the results and convert recursion to iteration, they are exactly the same algorithm. I guess recursive version expresses the idea better, maybe. --Ledrug 05:18, 21 June 2011 (UTC)

Hough transform C code

Rather than adding {{incorrect}}, it's probably more appropriate to just fix the code. Also, while I definitely appreciate the expertise and perspective I've seen you bringing to many areas across the wiki, calling code out as a 'shame', particularly in the page body itself, is inappropriate. Since the code implements the task, it's technically correct. If you'd like to raise suggested fixes (without implementing them yourself), you should raise them in the talk pages, as you've been doing elsewhere. --Michael Mol 01:10, 23 June 2011 (UTC)

Point 3 was minor, the key issue was the black artifact at bottom and the processing order. Yes I shouldn't called it a shame, sorry. I was looking at coding it, but I need to simple down the lib requirement first. --Ledrug 01:14, 23 June 2011 (UTC)

Welcome

Not going to drop the boilerplate greeting; I need to update it, I think. However, I've seen you as one of a few particularly active new users in the last few months, you've been getting a feel for the wiki and its habits, and it's pretty cool. Keep it up! :) --Michael Mol 01:11, 23 June 2011 (UTC)

Thanks! --Ledrug
Return to the user page of "Ledrug".