18-Maps_and_Multimaps

18-Maps_and_Multimaps - Character to Code Mapping Recall...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Recall Huffman Codec… To find Huffman code for a character one had to search the Huffman tree – O(N) Alternatively, one could store Huffman character codes in array, but the linear search is still – O(N) SLOW! Some of you stored Huffman codes in a string[256] array (256 ASCII characters) and achieved O(1) string charCode = HuffmanCodes[aChar]; SMART! But what if you had more than 256 characters? With UNICODE you can get 65536 glyphs, but generally much fewer would appear in encoded data. Array is FAST , but inefficient storage-wise. There is a better way. .. Character to Code Mapping Character to Code Mapping
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Definition: Map is a set of key/value pairs. Keys are mapped to values. Example: {(e, 1), (a, 01), (b, 011), (z, 111)} Keys: e, a, b, z Values: 1, 01, 011, 111 Key must be unique: Map presumes that for each key there is only one value. Value must not be unique: Different keys can be associated with the same value. Key/value relation:
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 8

18-Maps_and_Multimaps - Character to Code Mapping Recall...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online