Here's a pretty naive algorithm:
- Select the start line arbitrarily and write to the compression stream.
- The remaining lines are> 0:
- Save state of compression stream
- For each remaining line in a text file:
- write a string to the compression stream and write the resulting compressed length
- return to saved state of compression stream
- Write the line that led to the smallest compressed length in the compression stream
- Free Saved State
, , , . O (n 2), , . , : , , .
zlib, deflateCopy, , , -, .
: , "" , . , . TSP , /