Unary coding: Difference between revisions

Content deleted Content added
Line 77:
| colspan="3" | ...
|}
These codes are guaranteed to end validly on any length of data ( when reading arbitrary data ) and in the ( separate ) write cycle allow for the use and transmission of an extra bit ( the one used for the first bit ) while maintaining overall and per-integer unary code lengths of exactly N.
 
==Uniquely decodable non-prefix unary codes==
Following is an example of [[Uniquely decodable code|uniquely decodable]] unary codes that is not a [[prefix code]] and is not instantaneously decodable ([http://www.cs.ucf.edu/courses/cap5015/Huff.pdf need look-ahead to decode])
{| class="wikitable"
! n !! Unary code
!Alternative
|-
| 1 || 1
|0
|-
| 2 || 10
|01
|-
| 3 || 100
|011
|-
| 4 || 1000
|0111
|-
| 5 || 10000
|01111
|-
| 6 || 100000
|011111
|-
| 7 || 1000000
|0111111
|-
| 8 || 10000000
|01111111
|-
| 9 || 100000000
|011111111
|-
| 10 || 1000000000
|0111111111
|-
| colspan="23" | ...
|}
These codes also ( when writing unsigned integers ) allow for the use and transmission of an extra bit ( the one used for the first bit ). Thus they are able to transmit 'm' integers * N unary bits and 1 additional bit of information within m*N bits of data.
 
==Symmetric unary codes==
Following set of unary codes are symmetric and can be read in any direction. It is also instantaneously decodable in either direction.