Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
courses:cs211:winter2018:journals:hornsbym:chapter_4 [2018/03/12 01:58] hornsbymcourses:cs211:winter2018:journals:hornsbym:chapter_4 [2018/03/12 02:59] (current) – [Section 4.8 (Huffman Codes)] hornsbym
Line 47: Line 47:
 ===== Section 4.7 (Clustering) ===== ===== Section 4.7 (Clustering) =====
 ===== Section 4.8 (Huffman Codes) ===== ===== Section 4.8 (Huffman Codes) =====
- +Huffman codes compress data. Computers operate by producing and reading bits, which are sequences of 0's and 1's. Each sequence is assigned some piece of information that the computer can understand, so the problem is centered around picking the most efficient way of assigning sequences to information so that the most used information is assigned to the least costly sequence. Huffman codes do that exactly.\\ 
 +\\ 
 +Huffman codes use trees to organize and locate data. All data are stored in the leaf nodes of the tree, with the parent nodes being empty. As the computer reads through each bit, it traverses through the tree until it lands on a leaf node. Then, it returns that datum and reads through the next bit. It assigns O and 1 to a traversal to either the left or right child node, which guarantees that no two data will have the same encoding.\\ 
 +\\ 
 +What makes this algorithm work efficiently is that the trees are not always full. The most common data will be placed near the top of the tree, so that they are reached first. The book uses commonly used letters as an example. It would not makes sense for the letter 'e' to take up the same amount of space as a 'z' or 'q', since 'e' is more commonly used. Therefore, the trees can be somewhat skinny, but any given input will most likely not end up traversing the entire tree.\\ 
 +\\ 
 +If we use a heap priority queue to implement Huffman's algorithm, we can achieve O(//n// log//n//), with //n// representing the letters of the given alphabet. Heaps are trees that allow us to make insertions and deletions in O(log//n//) time. These operations are ideal for Huffman's algorithm, and so priority queues are the ideal data structure to use.
courses/cs211/winter2018/journals/hornsbym/chapter_4.1520819895.txt.gz · Last modified: by hornsbym
CC Attribution-Noncommercial-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0