Best Compression algorithm for a sequence of integers

前端 未结 15 1608
离开以前
离开以前 2020-11-29 16:41

I have a large array with a range of integers that are mostly continuous, eg 1-100, 110-160, etc. All integers are positive. What would be the best algorithm to compress thi

15条回答
  •  情歌与酒
    2020-11-29 17:40

    I'd combine the answers given by CesarB and Fernando Miguélez.

    First, store the differences between each value and the previous one. As CesarB pointed out, this will give you a sequence of mostly ones.

    Then, use a Run Length Encoding compression algorithm on this sequence. It will compress very nicely due to the large number of repeated values.

提交回复
热议问题