简体   繁体   中英

How to find longest common subsequence in multiple binary files?

I am given 10 binary files and I have to find the longest strand of bytes that is identical between two or more files. Any help is appreciated. Thanks in advance.

  • A brute force approach would be to compare each file to any other file, which would require 10 * 9 = 90 comparisons.

  • And for comparing any two files, you could just run through them bytewise and compare if they are equal, and then along the way you store the longest sequence found so far. Any time a sequence breaks, you start a new temporary sequence and only store it when it is longer than the original.

  • Another but somewhat similar approach is to use dynamic programming for the longest common subsequence (LCS) but requires more memory than the previous so depends on the size of the files and etc., but for this approach, there are plenty of resources with graphic visualizations and pseudo-code of the algorithm.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM