L20_Trie

# L20_Trie - Trie The next Data Structure that we learn is called a Trie'a'e'i's't\n Page 1 of 15 A trie is a binary tree that can be used for coding

This preview shows pages 1–7. Sign up to view the full content.

Trie The next Data Structure that we learn is called a Trie . '\n' ' ' 't' 's' 'i' 'e' 'a' Page 1 of 15

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

View Full Document
A trie is a binary tree that can be used for coding of documents. Such an encoding is known as a prefix code . i see a seat it is tea '\n' ' ' 't' 's' 'i' 'e' 'a' (Suppose the document only has a’s, e’s, i’s, s’s, t’s, spaces and newlines – and no other characters.) Page 2 of 15
Class Discussion y Is this trie good? '\n' ' ' 't' 's' 'i' 'e' 'a' Page 3 of 15

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

View Full Document
Cost of a Trie Suppose there are totally 10 a’s, 15 e’s, 12 i’s, 3 s’s, 4 t’s, 13 spaces and 1 newline in the document. CHAR CODE FREQ TOTAL BITS 'a' 000 10 30 'e' 001 15 45 'i' 010 12 36 's' 011 3 9 't' 100 4 12 ' ' 101 13 39 '\n' 110 1 3 Total 174 '\n' ' ' 't' 's' 'i' 'e' 'a' Page 4 of 15
Cost of a Trie A slightly better trie. CHAR CODE FREQ TOTAL BITS 'a' 000 10 30 'e' 001 15 45 'i' 010 12 36 's' 011 3 9 't' 100 4 12 ' ' 101 13 39 '\n' 11 1 2 Total 173 '\n' ' ' 't' 's' 'i' 'e' 'a' Page 5 of 15

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

View Full Document
CHAR CODE FREQ TOTAL BITS 'X' 10 'Y' 3 Total What is the ‘best’ trie? Page 6 of 15
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 12/28/2010 for the course CSC CSC1110 taught by Professor Cjyuan during the Fall '06 term at CUHK.

### Page1 / 15

L20_Trie - Trie The next Data Structure that we learn is called a Trie'a'e'i's't\n Page 1 of 15 A trie is a binary tree that can be used for coding

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

View Full Document
Ask a homework question - tutors are online