crc32 - CRC of concatenated input with known CRCs -


this question has answer here:

if have substrings s0, s1, ... sn calculated crcs c0, c1, ... cn, able determine crc c0...n of concatenated input s0s1...sn substantially greater efficiency linearly processing whole string?

obviously, c0...n = crc(s1...n, initialized c0), i'd know whether c0...n = f(c0,c1,...cn) f() o(n) complexity instead of o(|s0s1...sn|).

yes. can see how in implementation of crc32_combine() in zlib. takes crc1, crc2, , len2, len2 number of bytes in block on crc2 calculated. takes o(log(len2)) time. combination can repeated following blocks.

the approach continue crc calculation on crc1, following len2 0 bytes, , exclusive-or crc2. len2 bytes applied 0 operator repeatedly squared , applied each 1 bit in len2, permits o(log(len2)) execution time. routine added zlib in 2004.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -