pseudocode - LZW-decompressor algorithm -


i'm having hard time understand lzw algorithm. i'm examining pseudocode supplied on wikipedia (http://en.wikipedia.org/w/index.php?title=lempel-ziv-welch&oldid=245292660) , there's 1 part in decompressor code don't understand:

      else if (k == currsizedict)           entry = w + w[0]; 

can explain me scenario happen?

this problem explained here: https://www.cs.duke.edu/csed/curious/compression/lzw.html. basic idea since lzw requires compressed string , dictionary containing elements of alphabet (rather dictionary containing encoded patterns), it's necessary reconstruct encodings of more complex patterns on fly while decoding. results in situation it's possible run encodings aren't in dictionary. interestingly enough, link above points out, can happen when encoded string begins , ends same character.


Comments

Popular posts from this blog

angularjs - Showing an empty as first option in select tag -

qt - Change color of QGraphicsView rubber band -

php - Cloud9 cloud IDE and CakePHP -