开发者

Merge two strings (text files) [duplicate]

This questio开发者_JS百科n already has answers here: Closed 12 years ago.

Possible Duplicate:

Any decent text diff/merge engine for .NET ?

I got two text files that I would like to merge in some way. The first is just a edited version of the second.

Are there any open source tools available which can help me with that?

Edit: I want to find the changes between the two files and merge them as subversion does when it updates code files.


See example in this arkicle: http://en.wikipedia.org/wiki/Longest_common_subsequence_problem.

Firstly you have two big files. Then you should find their longest common subsequence (LCS) and divide files to three parts:

1: Before LCS;
2: LCS;
3: After LCS.

Then you should compare independent parts "1" and parts "2" (you have a recursion). Iteratively you decrease secuence to compare.

Total complexity will be between O(n*log(n)) and O(n*n).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜