3 25 13
play

3/25/13 CS200 Algorithms and Data Structures Colorado State - PDF document

3/25/13 CS200 Algorithms and Data Structures Colorado State University CS200 Algorithms and Data Structures Colorado State University PA3: Com ompres essing Data using Huffm Hu ffman Cod oding Sangmi Pallickara 3/25/13 2 Samgmi


  1. 3/25/13 ¡ CS200 Algorithms and Data Structures Colorado State University CS200 Algorithms and Data Structures Colorado State University PA3: Com ompres essing Data using Huffm Hu ffman Cod oding Sangmi Pallickara 3/25/13 2 Samgmi Lee Pallickara CS200 Algorithms and Data Structures Colorado State University CS200 Algorithms and Data Structures Colorado State University Hu Huffm ffman cod oding? Com ompres essing Data using Hu Huffm ffman Cod oding • Take String input • Uses the symbols and their frequencies • Generate compressed bits • Constructs rooted binary tree – Symbols are stored in the leaves • Example: • AEMMMEEKKMAABBBEEEEGGGMMMGGK MGKKKKKMMMMAKKKKMEGGGKKKKKKBB EEEEMGGGMMMABBMMABBBMMMMGGGM MMMMMMKKKMMMAAMM CS200 Algorithms and Data Structures Colorado State University CS200 Algorithms and Data Structures Colorado State University Crea eate e a Fr Freq equen ency table e Start fr from om a For Fores est of of Trees ees Character ¡ Frequency ¡ Huffman ¡code ¡ A ¡ 8 ¡ B ¡ 10 ¡ E ¡ 12 ¡ G ¡ 15 ¡ K ¡ 20 ¡ M ¡ 35 ¡ 1 ¡

  2. 3/25/13 ¡ CS200 Algorithms and Data Structures Colorado State University CS200 Algorithms and Data Structures Colorado State University Gen ener erate e Hu Huffm ffman cod ode e Character ¡ Frequency ¡ Huffman ¡code ¡ A ¡ 8 ¡ 111 ¡ B ¡ 10 ¡ 110 ¡ E ¡ 12 ¡ 011 ¡ G ¡ 15 ¡ 010 ¡ K ¡ 20 ¡ 10 ¡ M ¡ 35 ¡ 00 ¡ CS200 Algorithms and Data Structures Colorado State University CS200 Algorithms and Data Structures Colorado State University Now ow, en encod ode e you our string Dec ecod ode e the e string • AEMMMEEKKMAABBBEEEEGGGMMMGGK • If your encoded bit is 11100011 and you have MGKKKKKMMMMAKKKKMEGGGKKKKKKBB the Huffman Tree, EEEEMGGGMMMABBMMABBBMMMMGGGM MMMMMMKKKMMMAAMM  • 111(A) • 011(E) • 00(M) • … CS200 Algorithms and Data Structures Colorado State University CS200 Algorithms and Data Structures Colorado State University Exer ercise e Build a Hu Huffm ffman Tree ee based ed on on the e table e • Build a Huffman Frequency Table for, “Colorado” Assume that each of the symbols are Java char (16-bit unicode character) 3/25/13 Samgmi Lee Pallickara 11 3/25/13 Samgmi Lee Pallickara 12 2 ¡

  3. 3/25/13 ¡ CS200 Algorithms and Data Structures Colorado State University CS200 Algorithms and Data Structures Colorado State University Encod ode e the e String Dec ecod ode e it 3/25/13 13 3/25/13 14 Samgmi Lee Pallickara Samgmi Lee Pallickara CS200 Algorithms and Data Structures Colorado State University CS200 Algorithms and Data Structures Colorado State University You our tes est ou output will look ook like, e, % java PA3_Test eeyjjjj � • Write the implementer’s name(s) on top of each ====================================== � of the source code char frequency code � -------------------------------------- � • Work with the same partner (unless you get an e 2 10 � y 1 11 � email after this class) j 4 0 � ====================================== � Encoded bit stream � 1010110000 � Total number of bits without Huffman coding: 112 � Total number of bits with Huffman coding: 10 � Decoded String: eeyjjjj � 3 ¡

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend