Finding the optimal partitioning is going to be at least O(n2) no matter what. That is the reason realworld compression dictionary compression algorithms don't try to find the optimal partitioning. LZ77 works with a fixed-size window into the input that is usually relatively small. LZ78 works greedily (and takes a while to build up a usefully populated dictionary).

In general, your description sounds like something close to the LZ77 family. Typically, achieving speed with these algorithms is done by building a binary tree out of the window's contents, which allows rapid lookup of possible string matches and can be maintained very cheaply with a few tricks. It also means you can grow the buffer to decent sizes (typically 64k or so) because time spent on lookups only grows by log2 n in relation to the buffer size, which easily amortizes the memory and cycles for the tree.

What constraints are you working within? They have a huge impact on solutions, and you haven't told us much yet. Is your input size bounded in any way? What ballpark is the maximum repetition counter you can store, and the repeated string's maximum length?

Makeshifts last the longest.


In reply to Re: String Compression Optimization (repeated concatenated subsequences) by Aristotle
in thread String Compression Optimization (repeated concatenated subsequences) by QM

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.