Huffman Codes ASCII is a fixed length 7 bit code that uses the same number of bits to define each character regardless of how frequently it occurs. Huffman.

Slides:



Advertisements
Similar presentations
Functional Programming Lecture 15 - Case Study: Huffman Codes.
Advertisements

Lecture 4 (week 2) Source Coding and Compression
Michael Alves, Patrick Dugan, Robert Daniels, Carlos Vicuna
Greedy Algorithms (Huffman Coding)
Lecture 10 : Huffman Encoding Bong-Soo Sohn Assistant Professor School of Computer Science and Engineering Chung-Ang University Lecture notes : courtesy.
Data Compressor---Huffman Encoding and Decoding. Huffman Encoding Compression Typically, in files and messages, Each character requires 1 byte or 8 bits.
Huffman Encoding 16-Apr-17.
Huffman Coding: An Application of Binary Trees and Priority Queues
A Data Compression Algorithm: Huffman Compression
Is ASCII the only way? For computers to do anything (besides sit on a desk and collect dust) they need two things: 1. PROGRAMS 2. DATA A program is a.
Information Theory Eighteenth Meeting. A Communication Model Messages are produced by a source transmitted over a channel to the destination. encoded.
Data Structures – LECTURE 10 Huffman coding
Chapter 9: Huffman Codes
Q&A II – Sunday Feb 13 th 2011 BITS. Signed binary  What are the following numbers in signed binary?     
Fundamentals of Multimedia Chapter 7 Lossless Compression Algorithms Ze-Nian Li and Mark S. Drew 건국대학교 인터넷미디어공학부 임 창 훈.
Lossless Data Compression Using run-length and Huffman Compression pages
Trees1 Trees and Codes a bc de abcde.
Huffman code uses a different number of bits used to encode characters: it uses fewer bits to represent common characters and more bits to represent rare.
Data Structures and Algorithms Huffman compression: An Application of Binary Trees and Priority Queues.
Algorithm Design & Analysis – CS632 Group Project Group Members Bijay Nepal James Hansen-Quartey Winter
Huffman Codes. Encoding messages  Encode a message composed of a string of characters  Codes used by computer systems  ASCII uses 8 bits per character.
Huffman Encoding Veronica Morales.
Lecture Objectives  To learn how to use a Huffman tree to encode characters using fewer bytes than ASCII or Unicode, resulting in smaller files and reduced.
Lecture 18 Tree Traversal CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine.
Data Structures Week 6: Assignment #2 Problem
 The amount of data we deal with is getting larger  Not only do larger files require more disk space, they take longer to transmit  Many times files.
Communication Technology in a Changing World Week 2.
Compression.  Compression ratio: how much is the size reduced?  Symmetric/asymmetric: time difference to compress, decompress?  Lossless; lossy: any.
ICS 220 – Data Structures and Algorithms Lecture 11 Dr. Ken Cosh.
ALGORITHMS FOR ISNE DR. KENNETH COSH WEEK 13.
Huffman Coding. Huffman codes can be used to compress information –Like WinZip – although WinZip doesn’t use the Huffman algorithm –JPEGs do use Huffman.
Lossless Compression CIS 465 Multimedia. Compression Compression: the process of coding that will effectively reduce the total number of bits needed to.
Prof. Amr Goneid, AUC1 Analysis & Design of Algorithms (CSCE 321) Prof. Amr Goneid Department of Computer Science, AUC Part 8. Greedy Algorithms.
Huffman coding Content 1 Encoding and decoding messages Fixed-length coding Variable-length coding 2 Huffman coding.
Huffman Code and Data Decomposition Pranav Shah CS157B.
Priority Queues, Trees, and Huffman Encoding CS 244 This presentation requires Audio Enabled Brent M. Dingle, Ph.D. Game Design and Development Program.
Huffman Codes Juan A. Rodriguez CS 326 5/13/2003.
CS654: Digital Image Analysis Lecture 34: Different Coding Techniques.
Huffman’s Algorithm 11/02/ Weighted 2-tree A weighted 2-tree T is an extended binary tree with n external nodes and each of the external nodes is.
Foundation of Computing Systems
Bahareh Sarrafzadeh 6111 Fall 2009
1 Algorithms CSCI 235, Fall 2015 Lecture 30 More Greedy Algorithms.
Lossless Decomposition and Huffman Codes Sophia Soohoo CS 157B.
1 Data Compression Hae-sun Jung CS146 Dr. Sin-Min Lee Spring 2004.
1 Huffman Codes. 2 ASCII use same size encoding for all characters. Variable length codes can produce shorter messages than fixed length codes Huffman.
Chapter 7 Lossless Compression Algorithms 7.1 Introduction 7.2 Basics of Information Theory 7.3 Run-Length Coding 7.4 Variable-Length Coding (VLC) 7.5.
Lecture 12 Huffman Algorithm. In computer science and information theory, a Huffman code is a particular type of optimal prefix code that is commonly.
بسم الله الرحمن الرحيم My Project Huffman Code. Introduction Introduction Encoding And Decoding Encoding And Decoding Applications Applications Advantages.
Huffman code and Lossless Decomposition Prof. Sin-Min Lee Department of Computer Science.
3.3 Fundamentals of data representation
Design & Analysis of Algorithm Huffman Coding
Expression Tree The inner nodes contain operators while leaf nodes contain operands. a c + b g * d e f Start of lecture 25.
HUFFMAN CODES.
COMP261 Lecture 22 Data Compression 2.
Increasing Information per Bit
Algorithms for iSNE Dr. Kenneth Cosh Week 13.
ISNE101 – Introduction to Information Systems and Network Engineering
Data Compression If you’ve ever sent a large file to a friend, you may have compressed it into a zip archive like the one on this slide before doing so.
The Huffman Algorithm We use Huffman algorithm to encode a long message as a long bit string - by assigning a bit string code to each symbol of the alphabet.
Chapter 9: Huffman Codes
Math 221 Huffman Codes.
Huffman Coding CSE 373 Data Structures.
Communication Technology in a Changing World
Communication Technology in a Changing World
Huffman Encoding Huffman code is method for the compression for standard text documents. It makes use of a binary tree to develop codes of varying lengths.
Digital Encodings.
File Compression Even though disks have gotten bigger, we are still running short on disk space A common technique is to compress files so that they take.
Huffman Encoding.
Algorithms CSCI 235, Spring 2019 Lecture 30 More Greedy Algorithms
Algorithms CSCI 235, Spring 2019 Lecture 31 Huffman Codes
Presentation transcript:

Huffman Codes ASCII is a fixed length 7 bit code that uses the same number of bits to define each character regardless of how frequently it occurs. Huffman codes can represent data more efficiently by assigning shorter codes to characters that occur frequently and longer codes to characters that occur less frequently If the bit patterns are chosen carefully, ambiguity can be avoided This can be done by making use of the properties of a binary tree, called a Huffman Tree 2/11/10 05-Huffman

Example 1 AGAIN AND AGAIN AND AGAIN Derive a Huffman Code to encode the phrase: AGAIN AND AGAIN AND AGAIN This was part of a question in 2000, worth just 4 marks (i.e. it should be done in about 7 minutes) It is rather hard for an exam question. 2/11/10 05-Huffman

Step 1- Count the frequency of each symbol 8 G 3 I N 5 D 2 _ 4 Total 25 2/11/10 05-Huffman

Step 2 – Write out symbols and in order of their frequency 8 5 4 3 2 A N _ G I D If two symbols have the same frequency then they can be ordered arbitrarily. The decision will alter the coding of each symbol, but not the number of bits used to represent each symbol 2/11/10 05-Huffman

Step 3 – Combine the two lowest frequency symbols from the right into a tree and add their frequencies together. 2/11/10 05-Huffman

Step 4 – Reorder the tree using the new combined value 2/11/10 05-Huffman

Keep repeating Steps 3 and 4 until there is a single tree Combine 2/11/10 05-Huffman

Re-order 2/11/10 05-Huffman

Combine 2/11/10 05-Huffman

Re-order 2/11/10 05-Huffman

Combine 2/11/10 05-Huffman

Re-order 2/11/10 05-Huffman

The Huffman Tree is now complete Combine The Huffman Tree is now complete 2/11/10 05-Huffman

To derive a code for a symbol, start at the root and follow the path to the symbol. Write a 0 every time you go left and a 1 every time you go right 1 A 00 N 11 _ 010 G 011 I 100 D 101 2/11/10 05-Huffman

Encode the String “GAINING” 011 A 00 I 100 N 11 1 2/11/10 05-Huffman

Decode the Huffman Code 011001001110011011 G A I N I N G Traverse the tree by moving left for 0 and right for 1 until you reach a leaf, write down the symbol. Start again for the next symbol 1 2/11/10 05-Huffman

Question from the 2002 exam Given an alphabet code below that is derived from a Huffman coding, decode the entire message below: 010000111000000000000010001011111001010111100 A 000 H 100 S 11101 B 001 N 101 T 11110 C 010000 P 110 U 11111 D 010001 Q 111000 E 010110 G 011 R 111001 F 010111 2/11/10 05-Huffman

Huffman Tree for the 2002 exam question 2/11/10 05-Huffman

Answer from the 2002 exam CQAAADGRFH 2/11/10 05-Huffman

Exercise Using the following Huffman code mappings, send a short (one word) Huffman-coded message to your neighbour for him/her to decode using a Huffman tree 2/11/10 05-Huffman

Huffman Code Table for the Alphabet 2/11/10 05-Huffman

Huffman Tree for the Alphabet I S O N R H L W V Y D M G P U B T C F K X J Q Z Root 2/11/10 05-Huffman