CS 206 Introduction to Computer Science II 12 / 10 / 2008 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 –??
Greedy Algorithms Amihood Amir Bar-Ilan University.
CS 206 Introduction to Computer Science II 11 / 07 / 2008 Instructor: Michael Eckmann.
Data Compressor---Huffman Encoding and Decoding. Huffman Encoding Compression Typically, in files and messages, Each character requires 1 byte or 8 bits.
CS 206 Introduction to Computer Science II 04 / 28 / 2009 Instructor: Michael Eckmann.
Data Structures Data Structures Topic #13. Today’s Agenda Sorting Algorithms: Recursive –mergesort –quicksort As we learn about each sorting algorithm,
CS 206 Introduction to Computer Science II 04 / 27 / 2009 Instructor: Michael Eckmann.
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.
CS 206 Introduction to Computer Science II 12 / 09 / 2009 Instructor: Michael Eckmann.
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.
CS 206 Introduction to Computer Science II 10 / 31 / 2008 Happy Halloween!!! Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 12 / 05 / 2008 Instructor: Michael Eckmann.
A Data Compression Algorithm: Huffman Compression
DL Compression – Beeri/Feitelson1 Compression דחיסה Introduction Information theory Text compression IL compression.
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 12 / 03 / 2008 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 11 / 05 / 2008 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 04 / 29 / 2009 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 03 / 25 / 2009 Instructor: Michael Eckmann.
Chapter 9: Huffman Codes
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.
CS 206 Introduction to Computer Science II 02 / 11 / 2009 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 03 / 30 / 2009 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 10 / 08 / 2008 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 12 / 08 / 2008 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 10 / 28 / 2009 Instructor: Michael Eckmann.
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
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.
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.
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.
Priority Queues, Trees, and Huffman Encoding CS 244 This presentation requires Audio Enabled Brent M. Dingle, Ph.D. Game Design and Development Program.
CS 206 Introduction to Computer Science II 04 / 22 / 2009 Instructor: Michael Eckmann.
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.
CS 206 Introduction to Computer Science II 10 / 02 / 2009 Instructor: Michael Eckmann.
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.
CS 206 Introduction to Computer Science II 10 / 10 / 2008 Instructor: Michael Eckmann.
Chapter 11. Chapter Summary  Introduction to trees (11.1)  Application of trees (11.2)  Tree traversal (11.3)  Spanning trees (11.4)
Design & Analysis of Algorithm Huffman Coding
HUFFMAN CODES.
Compression & Huffman Codes
Fundamentals of Programming II Introduction to Trees
Top 50 Data Structures Interview Questions
CS302 Data Structures Fall 2012.
Chapter 8 – Binary Search Tree
Chapter 9: Huffman Codes
Algorithms (2IL15) – Lecture 2
Huffman Coding CSE 373 Data Structures.
Data Structure and Algorithms
Algorithms CSCI 235, Spring 2019 Lecture 30 More Greedy Algorithms
Presentation transcript:

CS 206 Introduction to Computer Science II 12 / 10 / 2008 Instructor: Michael Eckmann

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

Let's discuss a similar algorithm that solves the Selection problem. The selection problem is the desire to find the kth smallest item in an unsorted list. (e.g. in a list indexed from 0 to 99, if we wanted to find the 3 rd smallest item, k=3 and if our list was sorted (which it isn't) this item would live at index 2)‏ We can use the partition ideas from quicksort. If the pivot happens to live at index k-1, we're done. If not, then focus only on the side of the pivot that k is on. That is, if pivot happens to be at index j after partitioning, then if k-1 j then only work on the right list and if k-1==j, then we're done. Let's see if we can code this now. Selection problem

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 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. 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 it's 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