1 / 16

CSCE 310 Data Structures Algorithms

Giving credit where credit is due:Most of slides for this lecture are based on slides created by Dr. Richard Anderson, University of Washington.I have modified them and added new slides. CSCE 310 Data Structures

kaili
Download Presentation

CSCE 310 Data Structures Algorithms

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


    1. CSCE 310 Data Structures & Algorithms

    2. Giving credit where credit is due: Most of slides for this lecture are based on slides created by Dr. Richard Anderson, University of Washington. I have modified them and added new slides CSCE 310 Data Structures & Algorithms

    3. Coding theory ASCII coding Conversion, Encryption, Compression Binary coding

    4. Coding theory (cont.) ASCII coding Conversion, Encryption, Compression Binary coding

    5. Coding theory (cont.) ASCII coding Conversion, Encryption, Compression Binary coding Variable length coding Average bits/character = 2*0.3+3*0.1+3*0.1+3*0.1+2*0.3+3*0.1=2.4 Compression Ratio = (3-2.4)/3=20%Average bits/character = 2*0.3+3*0.1+3*0.1+3*0.1+2*0.3+3*0.1=2.4 Compression Ratio = (3-2.4)/3=20%

    6. Decode the following

    7. Prefix(-free) codes No prefix of a codeword is a codeword Uniquely decodable

    8. Prefix codes and binary trees Tree representation of prefix codes

    9. Construct the tree for the following code

    10. Minimum length code

    11. Minimum length code (cont.) Average leaf depth Huffman tree – tree with minimum weighted path length C(T) – weighted path length

    12. Compute average leaf depth (weighted path length) 1/4*2+1/8*3+1/16*4+1/16*4+1/2*1=1.8751/4*2+1/8*3+1/16*4+1/16*4+1/2*1=1.875

    13. Huffman code algorithm Derivation Two rarest items will have the longest codewords Codewords for rarest items differ only in the last bit Idea: suppose the weights are with and the smallest weights Start with an optimal code for and Extend the codeword for to get codewords for and

    14. Huffman code

    15. Example

    16. In-class exercises P332 Exercises 9.4.1

    17. In-class exercises 9.4.4 What is the maximal length of a codeword possible in a Huffman encoding of an alphabet of n characters? 9.4.6 Show that a Huffman tree can be constructed in linear time if the alphabet’s characters are given in a sorted order of their frequencies.

More Related