trees
Download
Skip this Video
Download Presentation
Trees

Loading in 2 Seconds...

play fullscreen
1 / 9

Trees - PowerPoint PPT Presentation


  • 151 Views
  • Uploaded on

Trees. Addenda. Huffman Codes. ASCII, EBCDIC (IBM Mainframes) & Unicode use 8 bits for all characters Morse code, others variable-length sequences. Variable-Length Codes. Each character has: Has a weight (a probability of ocurrence) A length Expected length of a string:

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Trees' - melchior


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
trees

Trees

Addenda

huffman codes
Huffman Codes
  • ASCII, EBCDIC (IBM Mainframes) & Unicode use 8 bits for all characters
  • Morse code, others
    • variable-length sequences
variable length codes
Variable-Length Codes
  • Each character has:
    • Has a weight (a probability of ocurrence)
    • A length
  • Expected length of a string:
    • sum of the products of the weights and lengths of all characters in string

ABCDE = 0.2 x 2 + 0.1 x 4 + 0.1 x 4 + 0.15 x 3 + 0.45 x 1 = 2.1

decoding
Decoding
  • Examine code string
  • When complete sequence found
    • Announce recognition of the character
    • Start decoding next character
immediate decodability
Immediate Decodability
  • No code sequence is a prefix of another code (i.e.; every code has a unique start)
    • Can be decoded without waiting for remaining bits

Must decode whole stringD is a prefix of B

NO

YES

huffman codes1
Huffman Codes
  • Immediately decodable
  • Minimal code length
  • Need an algorithm
    • Builds n-bit codes
huffman encoding
Huffman Encoding
  • Initialize list of n one-node binary trees T with a weight for each character
  • Do the following n – 1 times
    • Find two trees T\' and T" in list with minimal weights w\' and w"
    • Replace these two with 1 binary tree whose root is w\'+ w" and whose subtrees are T\' and T"
    • label the subtree edges: 0 and 1
    • the code for character Ci is the bit string of labels from the root to Ci
huffman encoding example
Huffman Encoding (Example)
  • Value of each parent=sum of children

1

0

1

.55

0

1

.2

.35

1

0

1

0

.1

.1

.15

.2

.45

B C D A E

huffman decoding
Huffman Decoding
  • Initialize pointer p to root of Huffman tree
  • While not end of message string:
    • a. Let xbe next bit in string
    • b. if x = 0 set p = left child pointer else set p = right child pointer
    • c. If p points to leaf
      • Display character with that leaf
      • Reset p to root of Huffman tree

e.g.; code string: 0001011010

B E A D

ad