CS 206 Introduction to Computer Science II 04 / 29 / 2009 Instructor: Michael Eckmann.

Slides:



Advertisements
Similar presentations
CS 206 Introduction to Computer Science II 02 / 27 / 2009 Instructor: Michael Eckmann.
Advertisements

Introduction to Computer Science 2 Lecture 7: Extended binary trees
Algorithm Design Techniques: Greedy Algorithms. Introduction Algorithm Design Techniques –Design of algorithms –Algorithms commonly used to solve problems.
Michael Alves, Patrick Dugan, Robert Daniels, Carlos Vicuna
Binary Trees CSC 220. Your Observations (so far data structures) Array –Unordered Add, delete, search –Ordered Linked List –??
Data Compressor---Huffman Encoding and Decoding. Huffman Encoding Compression Typically, in files and messages, Each character requires 1 byte or 8 bits.
CS 171: Introduction to Computer Science II
Trees Chapter 8.
Review. What to know You are responsible for all material covered in lecture, the readings, or the programming assignments There will also be some questions.
Compression & Huffman Codes
Fall 2007CS 2251 Trees Chapter 8. Fall 2007CS 2252 Chapter Objectives To learn how to use a tree to represent a hierarchical organization of information.
Trees Chapter 8. Chapter 8: Trees2 Chapter Objectives To learn how to use a tree to represent a hierarchical organization of information To learn how.
Trees Chapter 8. Chapter 8: Trees2 Chapter Objectives To learn how to use a tree to represent a hierarchical organization of information To learn how.
1 Assignment 2: (Due at 10:30 a.m on Friday of Week 10) Question 1 (Given in Tutorial 5) Question 2 (Given in Tutorial 7) If you do Question 1 only, you.
A Data Compression Algorithm: Huffman Compression
DL Compression – Beeri/Feitelson1 Compression דחיסה Introduction Information theory Text compression IL compression.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 26 Binary Search Trees.
CS 206 Introduction to Computer Science II 09 / 22 / 2008 Instructor: Michael Eckmann.
Compression & Huffman Codes Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
CS 206 Introduction to Computer Science II 11 / 03 / 2008 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 11 / 05 / 2008 Instructor: Michael Eckmann.
Chapter 9: Huffman Codes
CS 206 Introduction to Computer Science II 12 / 10 / 2008 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 11 / 24 / 2008 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 11 / 09 / 2009 Instructor: Michael Eckmann.
Data Compression Gabriel Laden CS146 – Dr. Sin-Min Lee Spring 2004.
CSE Lectures 22 – Huffman codes
CS 206 Introduction to Computer Science II 09 / 30 / 2009 Instructor: Michael Eckmann.
Data Structures Arrays both single and multiple dimensions Stacks Queues Trees Linked Lists.
Algorithm Design & Analysis – CS632 Group Project Group Members Bijay Nepal James Hansen-Quartey Winter
Data Compression1 File Compression Huffman Tries ABRACADABRA
Huffman Encoding Veronica Morales.
1 Analysis of Algorithms Chapter - 08 Data Compression.
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.
Ceng-112 Data Structures I 1 Chapter 7 Introduction to Trees.
Trees Chapter 8. Chapter 8: Trees2 Chapter Objectives To learn how to use a tree to represent a hierarchical organization of information To learn how.
Spring 2010CS 2251 Trees Chapter 6. Spring 2010CS 2252 Chapter Objectives Learn to use a tree to represent a hierarchical organization of information.
Dijkstra’s Algorithm. Announcements Assignment #2 Due Tonight Exams Graded Assignment #3 Posted.
Huffman Coding. Huffman codes can be used to compress information –Like WinZip – although WinZip doesn’t use the Huffman algorithm –JPEGs do use Huffman.
CS 206 Introduction to Computer Science II 09 / 10 / 2009 Instructor: Michael Eckmann.
Introduction to Algorithms Chapter 16: Greedy Algorithms.
Huffman coding Content 1 Encoding and decoding messages Fixed-length coding Variable-length coding 2 Huffman coding.
Final Exam Review CS Total Points – 60 Points Writing Programs – 50 Points Tracing Algorithms, determining results, and drawing pictures – 50.
Huffman Codes Juan A. Rodriguez CS 326 5/13/2003.
Computer Science 112 Fundamentals of Programming II Introduction to Trees.
© Copyright 2012 by Pearson Education, Inc. All Rights Reserved. 1 Chapter 19 Binary Search Trees.
CS654: Digital Image Analysis Lecture 34: Different Coding Techniques.
Course Review Fundamental Structures of Computer Science Margaret Reid-Miller 29 April 2004.
Lossless Decomposition and Huffman Codes Sophia Soohoo CS 157B.
Final Exam Review CS Total Points – 20 Points Writing Programs – 65 Points Tracing Algorithms, determining results, and drawing pictures – 50.
Chapter 11. Chapter Summary  Introduction to trees (11.1)  Application of trees (11.2)  Tree traversal (11.3)  Spanning trees (11.4)
Final Exam Review CS 3358.
Data Structures and Algorithms
Design & Analysis of Algorithm Huffman Coding
HUFFMAN CODES.
Compression & Huffman Codes
Chapter 25 Binary Search Trees
Assignment 6: Huffman Code Generation
Top 50 Data Structures Interview Questions
CSC 172– Data Structures and Algorithms
Data Structures and Algorithms
CS302 Data Structures Fall 2012.
Chapter 8 – Binary Search Tree
Chapter 9: Huffman Codes
Algorithms (2IL15) – Lecture 2
Chapter 11 Data Compression
Huffman Coding CSE 373 Data Structures.
Podcast Ch23d Title: Huffman Compression
Algorithms CSCI 235, Spring 2019 Lecture 30 More Greedy Algorithms
Presentation transcript:

CS 206 Introduction to Computer Science II 04 / 29 / 2009 Instructor: Michael Eckmann

Michael Eckmann - Skidmore College - CS Fall 2008 Today’s Topics Questions/comments? Compression / Huffman Coding Closing Remarks Evaluations

Compression is the idea of taking some input with some size and outputting a smaller sized output that represents the input. –If the input can be generated perfectly from the output by some reverse process then it is lossless compression. –If the input cannot be generated perfectly from the output by some reverse process then it is lossy compression. Example: an image w/ 656 x 434 color pixels (3 bytes per pixel)‏ –Uncompressed size = 656*434*3 = bytes –High quality lossy JPG compressed size = bytes –Low quality lossy JPG compressed size = bytes compression

Huffman coding is a lossless compression technique for text. Storage for ASCII is 8 bits per character and UNICODE is 16 bits per character. Given a file of characters we examine the characters and sort them by frequency. The ones that occur most frequently are represented with fewer bits and the ones most frequently occurring are represented with more bits. Hence this is a variable length coding algorithm. How does that result in compressed data? Huffman coding

Huffman codes for the characters can be generated by creating a tree where the characters are in leaf nodes and the paths from root to leaves create the huffman code for the character at the leaf. Each link is a 0 or 1. Huffman coding

1. Start out with a forest of trees, all being one node each. Each node represents a character and the frequency of that character. The weight of a tree is the sum of its nodes' frequencies and this weight is stored in the root. 2. while there's still more than one tree –The two trees (tree1 and tree2) with the smallest weights are joined together into one tree with the root set to have the weight as the sum of the two subtree weights and tree1 is the left subtree of the root and tree2 is the right subtree of the root 3. Assign a 0 to the left link and a 1 to the right link of each node and the tree generated above will be the optimal Huffman encoding tree. Let's see a small example of generating the huffman codes by creating a huffman tree: –Let's examine the text: “Java is a programming language.” Huffman coding

Note that no character encoding is a prefix of any other character encoding. What does that mean? Why is it necessary? Huffman coding

Huffman coding is an optimal coding for coding each symbol (character) independently. Other coding schemes could supply codes for a group characters and possibly get better compression. Huffman coding

From the syllabus Course Goals and Objectives 1. To understand, be able to use and be able to write computer programs utilizing the various data structures that we'll cover. 2. To understand, be able to use and be able to write computer programs utilizing the various algorithms that we'll cover. 3. To be able to, to some degree, analyze algorithms that solve the same problem. Then be able to determine which is more efficient and why. 4. To become more proficient computer programmers. Learn and practice good techniques for testing and debugging. Closing Remarks

What have we done this semester? –Learned many common data structures that are used extensively in computer science and how they are implemented Linked lists, doubly linked lists, etc. Trees, Binary Trees, BSTs Stack Queue Priority Queue Heap Graph (directed/undirected, weighted/unweighted)‏ Hash Table Balanced Trees (AVL, B-Tree)‏ Closing Remarks

What have we done this semester? –Learned many algorithms that use these data structures, implemented them and analyzed (to some extent) their running times Binary tree traversals – inorder, preorder, postorder Recursive algorithms, Divide and Conquer algorithms, Dynamic Programming algorithms Breadth First Search, Depth First Search, Dijkstra's MergeSort, RadixSort, HeapSort, QuickSort Selection Huffman coding algorithm –Gained more programming experience, especially with larger programs.. Closing Remarks

Our final exam is in this class room on Thursday May 7 th at 1:30pm. It will be part closed book and part open book/notes. A list of topics we covered in the course is posted on our class notes page to help you study. Final exam