-1
$\begingroup$

I'm looking for some common algos geared at storing arrays in a compact format using the underlying data particularities (and as such exceeding HEX and other encoders ratios), such as:

  • repeating items, which can be stored by-reference (ex. [index]a, where index is the first occurrence and a..z is the actual repetition)
  • sequential values, which can be presented by x..y
  • other ideas?? possibly "lingual" algos, using specially constructed dictionaries?

I have arrays of 100-10000 non-unique integers (%% of dups is 10%-40%), ranging from 0..255, which I need to store in a maximum compact way. I'd appreciate if anyone can point out any suitable algos.

New contributor
JsCoder is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
$\endgroup$
8
  • $\begingroup$ Storing in a "maximum compact way" will likely make it difficult to access the array. Is access time a consideration at all? $\endgroup$ Commented Dec 9 at 22:57
  • $\begingroup$ Not at all (within the reasonable boundaries). The array will always be decoded first thing, which is a one time expense. $\endgroup$
    – JsCoder
    Commented Dec 9 at 23:28
  • 1
    $\begingroup$ Are you looking for data compression? $\endgroup$
    – greybeard
    Commented Dec 10 at 8:46
  • $\begingroup$ that one, the lossless kind. $\endgroup$
    – JsCoder
    Commented Dec 10 at 9:38
  • 1
    $\begingroup$ You need to be more specific about what you're looking for. Data compression is a standard feature of most runtime libraries these days, and there are plenty of third-party data compression packages available. Are those not sufficient for your application? $\endgroup$ Commented Dec 10 at 16:19

1 Answer 1

0
$\begingroup$

Your problem is just compression. The array is irrelevant; you have some data (a sequence of bytes), and you want to compress it. The general approaches are to either use a general-purpose compression algorithm, or to design a custom algorithm given some prior knowledge about the distribution of data you're likely to encounter. It's not possible to give any concrete suggestions for the latter, as the best algorithm will depend on the specific distribution of data you are dealing with.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.