Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Lempel–Ziv–Welch
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Encoding=== Buffer input characters in a sequence ω until ω + next character is not in the dictionary. Emit the code for ω, and add ω + next character to the dictionary. Start buffering again with the next character. (The string to be encoded is "TOBEORNOTTOBEORTOBEORNOT#".) {| class="wikitable" style="text-align: right; margin-left: auto; margin-right: auto;" |- ! scope="col" width="6em" rowspan="2" | Current Sequence ! scope="col" width="4em" rowspan="2" | Next Char ! colspan="2" | Output ! scope="col" width="7em" rowspan="2" colspan="2" | Extended Dictionary ! rowspan="2" | Comments |- ! Code || Bits |- | style="text-align: center;" | NULL | style="text-align: center;" | T || || | style="border-right: none;" | | style="border-left: none;" | || |- | style="text-align: center;" | T | style="text-align: center;" | O | 20 || {{mono|10100}} | style="border-right: none;" | 27: | style="border-left: none;" | TO | style="text-align: left;" | 27 = first available code after 0 through 26 |- | style="text-align: center;" | O | style="text-align: center;" | B | 15 || {{mono|01111}} | style="border-right: none;" | 28: | style="border-left: none;" | OB || |- | style="text-align: center;" | B | style="text-align: center;" | E | 2 || {{mono|00010}} | style="border-right: none;" | 29: | style="border-left: none;" | BE || |- | style="text-align: center;" | E | style="text-align: center;" | O | 5 || {{mono|00101}} | style="border-right: none;" | 30: | style="border-left: none;" | EO || |- | style="text-align: center;" | O | style="text-align: center;" | R | 15 || {{mono|01111}} | style="border-right: none;" | 31: | style="border-left: none;" | OR || |- | style="text-align: center;" | R | style="text-align: center;" | N | 18 || {{mono|10010}} | style="border-right: none;" | 32: | style="border-left: none;" | RN | style="text-align: left;" | 32 requires 6 bits, so for next output use 6 bits |- | style="text-align: center;" | N | style="text-align: center;" | O | 14 || {{mono|001110}} | style="border-right: none;" | 33: | style="border-left: none;" | NO || |- | style="text-align: center;" | O | style="text-align: center;" | T | 15 || {{mono|001111}} | style="border-right: none;" | 34: | style="border-left: none;" | OT || |- | style="text-align: center;" | T | style="text-align: center;" | T | 20 || {{mono|010100}} | style="border-right: none;" | 35: | style="border-left: none;" | TT || |- | style="text-align: center;" | TO | style="text-align: center;" | B | 27 || {{mono|011011}} | style="border-right: none;" | 36: | style="border-left: none;" | TOB || |- | style="text-align: center;" | BE | style="text-align: center;" | O | 29 || {{mono|011101}} | style="border-right: none;" | 37: | style="border-left: none;" | BEO || |- | style="text-align: center;" | OR | style="text-align: center;" | T | 31 || {{mono|011111}} | style="border-right: none;" | 38: | style="border-left: none;" | ORT || |- | style="text-align: center;" | TOB | style="text-align: center;" | E | 36 || {{mono|100100}} | style="border-right: none;" | 39: | style="border-left: none;" | TOBE || |- | style="text-align: center;" | EO | style="text-align: center;" | R | 30 || {{mono|011110}} | style="border-right: none;" | 40: | style="border-left: none;" | EOR || |- | style="text-align: center;" | RN | style="text-align: center;" | O | 32 || {{mono|100000}} | style="border-right: none;" | 41: | style="border-left: none;" | RNO || |- | style="text-align: center;" | OT | style="text-align: center;" | # | 34 || {{mono|100010}} | style="border-right: none;" | | style="border-left: none;" | | style="text-align: left;" | # stops the algorithm; send the cur seq |- | || || 0 || {{mono|000000}} | style="border-right: none;" | | style="border-left: none;" | | style="text-align: left;" | and the stop code |- |} :Unencoded length = 25 symbols × 5 bits/symbol = 125 bits :Encoded length = (6 codes × 5 bits/code) + (11 codes × 6 bits/code) = 96 bits. Using LZW has saved 29 bits out of 125, reducing the message by more than 23%. If the message were longer, then the dictionary words would begin to represent longer and longer sections of text, sending repeated words very compactly.
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Lempel–Ziv–Welch
(section)
Add topic