NSArray-LongestCommonSubsequence
NSArray-LongestCommonSubsequence copied to clipboard
speed?
I just tried this and it works well, however it's not very fast with large collections.
I'm sure it has to do with having an array of 1150 ints that I like to diff. It takes a couple of seconds on my iPad. Is this to be expected?
I don't think it should take quite that long with only 1,000 items. It's an n² algorithm, so about 1,000,000 operations, but each iteration of the array is pretty fast. See the code here:
https://github.com/khanlou/NSArray-LongestCommonSubsequence/blob/master/LongestCommonSubsequence/NSArray%2BLongestCommonSubsequence.m#L37-L48
I would recommend using instruments or something to profile your code?