Patent ID: 8176234

Claim:
A computer implemented method for storing data comprising: receiving write data; receiving a write address of a memory page, the memory page being in either an erased state or a previously written state, the memory page associated with a plurality of memory cells having electrical charge levels; in response to the memory page being in the erased state: selecting a first codeword such that the first codeword encodes the write data and is consistent with a target set of distributions of electrical charge levels in the memory page; and writing the first codeword to the memory page; and in response to the memory page being in the previously written state: selecting a coset from a linear code such that the coset encodes the write data and includes one or more words that are consistent with previously written content of the memory page; selecting a subsequent codeword from the one or more words in the coset; and writing the subsequent codeword to the memory page.