Close
Close Window

CS3 Data Structures & Algorithms

Chapter 7 Binary Trees

| About   «  7.18. Huffman Coding Trees   ::   Contents   ::   7.20. Proof of Optimality for Huffman Coding  »

7.19. Trees versus Tries

7.19.1. Trees versus Tries

We see that all letters with codes beginning with ‘0’ are stored in the left branch, while all letters with codes beginning with ‘1’ are stored in the right branch. Contrast this with storing records in a BST. There, all records with key value less than the root value are stored in the left branch, while all records with key values greater than the root are stored in the right branch.

Recall that the Huffman coding tree stored in the left branch all letters whose codes start with 0, and in the right branch all letters whose codes start with 1. We can use this same concept to store records in a search tree that is slightly different from the behavior of a BST. We can view all keys stored as appearing on a numberline. The BST splits the numberline based on the positions of key values as it receives them. In contrast, we could split key values based on their binary reprsentation similar to what the Huffman coding tree does. The following slideshows present this in more detail.

1 / 13 Settings
<<<>>>

To demonstrate to characteristics of a tree, we will display this on a number line. We first insert 36.

Created with Raphaël 2.1.2
Created with Raphaël 2.1.2
36
0
70
Proficient Saving... Error Saving
Server Error
Resubmit


1 / 8 Settings
<<<>>>

To demonstrate to characteristics of a trie, we will display this on a number line. We start with an emtpy trie.

Created with Raphaël 2.1.2
Created with Raphaël 2.1.2
0
64
Proficient Saving... Error Saving
Server Error
Resubmit

   «  7.18. Huffman Coding Trees   ::   Contents   ::   7.20. Proof of Optimality for Huffman Coding  »

Close Window