Overheads for Computers as Components

Slides:



Advertisements
Similar presentations
Formal Language, chapter 4, slide 1Copyright © 2007 by Adam Webber Chapter Four: DFA Applications.
Advertisements

One Dimensional Arrays
Lecture 4 (week 2) Source Coding and Compression
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 –??
© 2008 Wayne Wolf Overheads for Computers as Components 2 nd ed. CPUs zExample: data compressor.
Chapter 3 CPUs 金仲達教授 清華大學資訊工程學系 (Slides are taken from the textbook slides)
A Data Compression Algorithm: Huffman Compression
Hash Tables1 Part E Hash Tables  
Hash Tables1 Part E Hash Tables  
Hash Tables1 Part E Hash Tables  
Data Structures and Algorithms Huffman compression: An Application of Binary Trees and Priority Queues.
1 Project 7: Huffman Code. 2 Extend the most recent version of the Huffman Code program to include decode information in the binary output file and use.
CS 46B: Introduction to Data Structures July 30 Class Meeting Department of Computer Science San Jose State University Summer 2015 Instructor: Ron Mak.
Noiseless Coding. Introduction Noiseless Coding Compression without distortion Basic Concept Symbols with lower probabilities are represented by the binary.
Algorithm Design & Analysis – CS632 Group Project Group Members Bijay Nepal James Hansen-Quartey Winter
CIS Computer Programming Logic
General Computer Science for Engineers CISC 106 Lecture 02 Dr. John Cavazos Computer and Information Sciences 09/03/2010.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 CST 221 OBJECT ORIENTED PROGRAMMING(OOP) ( 2 CREDITS.
Data Compression1 File Compression Huffman Tries ABRACADABRA
Cis303a_chapt03-2a.ppt Range Overflow Fixed length of bits to hold numeric data Can hold a maximum positive number (unsigned) X X X X X X X X X X X X X.
Stack. Abstract Data Types (ADTs) An abstract data type (ADT) is an abstraction of a data structure An ADT specifies: Data stored Operations on the data.
1 Huffman Codes Drozdek Chapter Objectives You will be able to Construct an optimal variable bit length code for an alphabet with known probability.
Compression.  Compression ratio: how much is the size reduced?  Symmetric/asymmetric: time difference to compress, decompress?  Lossless; lossy: any.
Property of Jack Wilson, Cerritos College1 CIS Computer Programming Logic Programming Concepts Overview prepared by Jack Wilson Cerritos College.
Huffman coding Content 1 Encoding and decoding messages Fixed-length coding Variable-length coding 2 Huffman coding.
© 2004 Goodrich, Tamassia Hash Tables1  
1 Chapter 7 Skip Lists and Hashing Part 2: Hashing.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
Main Index Contents 11 Main Index Contents Complete Binary Tree Example Complete Binary Tree Example Maximum and Minimum Heaps Example Maximum and Minimum.
1 Huffman Codes. 2 ASCII use same size encoding for all characters. Variable length codes can produce shorter messages than fixed length codes Huffman.
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.
Compression techniques Adaptive and non-adaptive.
© 2000 Morgan Kaufman Overheads for Computers as Components CPUs zExample: data compressor.
Prof. Paolo Ferragina, Algoritmi per "Information Retrieval" Basics
Stack. ADS2 Lecture 1010 The Stack ADT (GoTa §5.1) The Stack ADT stores arbitrary objects Insertions and deletions follow the last-in.
Review A program is… a set of instructions that tell a computer what to do. Programs can also be called… software. Hardware refers to… the physical components.
Computers’ Basic Organization
Chapter 1.2 Introduction to C++ Programming
3.3 Fundamentals of data representation
Chapter 1.2 Introduction to C++ Programming
HUFFMAN CODES.
Tries 07/28/16 11:04 Text Compression
Assignment 6: Huffman Code Generation
Chapter 1.2 Introduction to C++ Programming
IGCSE 4 Cambridge Data types and arrays Computer Science Section 2
Chapter 1.2 Introduction to C++ Programming
Overheads for Computers as Components
Instructor: David Ferry
Applied Algorithmics - week7
C Basics.
I/O Basics.
Lempel-Ziv-Welch (LZW) Compression Algorithm
Introduction to the C Language
Bits and Bytes Topics Representing information as bits
Bits and Bytes Topics Representing information as bits
CIS16 Application Development and Programming using Visual Basic.net
Advanced Algorithms Analysis and Design
Chapter Four: DFA Applications
Bits and Bytes Topics Representing information as bits
Overheads for Computers as Components 2nd ed.
Coding Concepts (Data- Types)
Your questions from last session
Spreadsheets, Modelling & Databases
Operations and Arithmetic
Introduction to Programming
Podcast Ch23d Title: Huffman Compression
CS210- Lecture 16 July 11, 2005 Agenda Maps and Dictionaries Map ADT
Huffman Coding Greedy Algorithm
Presentation transcript:

Overheads for Computers as Components CPUs Example: data compressor. © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components Goals Compress data transmitted over serial line. Receives byte-size input symbols. Produces output symbols packed into bytes. Will build software module only here. © 2000 Morgan Kaufman Overheads for Computers as Components

Collaboration diagram for compressor 1..m: packed output symbols 1..n: input symbols :input :data compressor :output © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components Huffman coding Early statistical text compression algorithm. Select non-uniform size codes. Use shorter codes for more common symbols. Use longer codes for less common symbols. To allow decoding, codes must have unique prefixes. No code can be a prefix of a longer valid code. © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components Huffman example character P a .45 b .24 c .11 d .08 e .07 f .05 P=1 P=.55 P=.31 P=.19 P=.12 © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components Example Huffman code Read code from root to leaves: a 1 b 01 c 0000 d 0001 e 0010 f 0011 © 2000 Morgan Kaufman Overheads for Computers as Components

Huffman coder requirements table © 2000 Morgan Kaufman Overheads for Computers as Components

Building a specification Collaboration diagram shows only steady-state input/output. A real system must: Accept an encoding table. Allow a system reset that flushes the compression buffer. © 2000 Morgan Kaufman Overheads for Computers as Components

data-compressor class buffer: data-buffer table: symbol-table current-bit: integer encode(): boolean, data-buffer flush() new-symbol-table() © 2000 Morgan Kaufman Overheads for Computers as Components

data-compressor behaviors encode: Takes one-byte input, generates packed encoded symbols and a Boolean indicating whether the buffer is full. new-symbol-table: installs new symbol table in object, throws away old table. flush: returns current state of buffer, including number of valid bits in buffer. © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components Auxiliary classes data-buffer symbol-table databuf[databuflen] : character len : integer symbols[nsymbols] : data-buffer len : integer insert() length() : integer value() : symbol load() © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components Auxiliary class roles data-buffer holds both packed and unpacked symbols. Longest Huffman code for 8-bit inputs is 256 bits. symbol-table indexes encoded verison of each symbol. load() puts data in a new symbol table. © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components Class relationships data-compressor 1 1 1 1 data-buffer symbol-table © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components Encode behavior create new buffer add to buffers return true T input symbol encode buffer filled? F add to buffer return false © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components Insert behavior pack into this buffer input symbol T update length fills buffer? F pack bottom bits into this buffer, top bits into overflow buffer © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components Program design In an object-oriented language, we can reflect the UML specification in the code more directly. In a non-object-oriented language, we must either: add code to provide object-oriented features; diverge from the specification structure. © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components C++ classes Class data_buffer { char databuf[databuflen]; int len; int length_in_chars() { return len/bitsperbyte; } public: void insert(data_buffer,data_buffer&); int length() { return len; } int length_in_bytes() { return (int)ceil(len/8.0); } int initialize(); ... © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components C++ classes, cont’d. class data_compressor { data_buffer buffer; int current_bit; symbol_table table; public: boolean encode(char,data_buffer&); void new_symbol_table(symbol_table); int flush(data_buffer&); data_compressor(); ~data_compressor(); } © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components C code struct data_compressor_struct { data_buffer buffer; int current_bit; sym_table table; } typedef struct data_compressor_struct data_compressor, *data_compressor_ptr; boolean data_compressor_encode(data_compressor_ptr mycmptrs, char isymbol, data_buffer *fullbuf) ... © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components Testing Test by encoding, then decoding: symbol table result input symbols encoder decoder compare © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components Code inspection tests Look at the code for potential problems: Can we run past end of symbol table? What happens when the next symbol does not fill the buffer? Does fill it? Do very long encoded symbols work properly? Very short symbols? Does flush() work properly? © 2000 Morgan Kaufman Overheads for Computers as Components