Program to create huffman codes

Assignment Help Data Structure & Algorithms
Reference no: EM13164975

Write a C++ program to create Huffman codes. Program input is a file called freq.txt (make up your own file for testing) that contains data on the characters in some cleartext file in the form of each character's non-zero frequency of occurrence in the cleartextfile. (Note that these are frequency counts, not percentages, and it doesn't matter if the values do not sum to 100.) You can assume that freq.txt contains only characters from the standard ASCII 128 character set and that the results are ordered by the ASCII integer for each character. The end-of-line character in a text file is a non-printable line feed character, with ASCII code 10, and will be written in the freq.txtfile as LF. Thus the freq.txt file might look like

LF 2

c 3

d 5

e 14

f 2

Your program should create a "code table" that gives each character and its binary Huffman code. Save this information in an external file called codetable.txt where each line of the file is a character and its code, ordered by the ASCII value of the character.

Reference no: EM13164975

Questions Cloud

What are the frequency and energy of a photon : What are the frequency and energy of a photon with a wavelength of 900 nm. Report your answers to three significant digits.
What are the masses and precent abundances of each : boron has two naturally occuring isotopes,, 10B (19.9%) and 11B(80.1. althought the b2 molecule doesn not exist naturally on earth, it been been produced in the laboratory and been observed in stars..
Overland flow paths from animal feedlots to nearest drainage : we are trying to determine the overland flow paths from animal feedlots to the nearest drainage. using a "least cost path" tool in GIS works about half the time (sometimes the flow path does not reach a drainage, other times it reaches the drainages ..
State the burning of sufficient magnesium in oxygen : The burning of sufficient magnesium in oxygen to form 2.00 grams of magnesium oxide results in the liberation of 30.1 kj.
Program to create huffman codes : Write a C++ program to create Huffman codes. Program input is a file called freq.txt (make up your own file for testing) that contains data on the characters in some cleartext file in the form of each character's non-zero frequency of occurrence i..
What is the new pressure in the bicycle tire : A bicycle tire is filled with air to a pressure of 75. psi at a temperature of 19 degrees celcius. Riding the bike on asphalt on a hot day increases the temperature of the tire to 58 degrees celcius. The volume of the tire increases by 4.0%. What ..
Compute the ph of the buffer after the addition : Calculate the pH of the buffer after the addition of 1.5 g of HCl (36.5 g/mol). (Ka of HNO2 = 7.1x10^-4.)
Compute the net realizable value at the end of 2011 : Compute the net realizable value at the end of 20X1 and 20X2 as a percentage of respective year-end receivables balances. Analyze your findings and comment on the president s decision to close the credit evaluation department.
Matlab that will use the flipping of two-sided coins to sim : Write a program in matlab that will use the flipping of two-sided coins to simulate any event that has a probability of success(Ps) that ranges between 0 and 1. The simulation will most likely be approximate. It must be accurate to at least 0.01

Reviews

Write a Review

 

Data Structure & Algorithms Questions & Answers

  Finding page faults for lru replacement algorithms

How many page faults would happen for the given replacement algorithms, assuming one, two, three, and four frames?

  Design benefits election system-service request from huffman

Individual project for this course is in form of Service Request from Huffman Trucking. It is essential for student to access Service Request: SR-ht-001. Design a Benefits Election System.

  Write efficient backtracking algorithm to inputs integers

Write efficient backtracking algorithm which inputs the integer N, and outputs all of the ways which a group of ascending positive numbers can be summed to N.

  Question about isdn

Today ISDN cost $40 every month for BRI service which includes 1 D Channel and 2 B Channels. Every channel is capable of transmitting 64kbps of voice, data, video or fax for a total of 128 kbps.

  Creating two arrays of integers

Prepare two arrays of integers, each holding 10-elements of data. Make a third array of integers for a result array. The main program will take the 2-arrays of integers and pass them to the function subtract().

  Find cost of sorting the relation

Suppose the cost of seek is 5milliseconds, while the disk transfer rate is 40 mgbytes per second. Find the cost of sorting the relation , in seconds, w/bb = 1 & w/ bb= 100.

  Algorithm to decide flavor of ice cream from three option

A group of ten people require to decide which one flavor of ice cream they will all order, out of three options. The algorithm can question and re-question participants.

  Estimate cost of multi phase multiway merge sort

Find out number of phases needed, and estimate cost of Multi Phase Multiway Merge Sort. Write all BCNF violations. Decompose relations, as essential, into collections of relations whic hare in BCNF.

  Question about pure aloha

A group of N stations share a 56-kbps pure ALOHA channel. Every station outputs a 1000-bit frame on an average of once every one-hundred secs, even if the previous one has not yet been sent.

  Data structures and algorithm design

Data Structures and Algorithm Design

  Write algorithm to find median value using queries

As queries are expensive, you would like to calculate median using as few queries as possible. Provide the algorithm which finds median value using at most O(log n) queries.

  Contents of registers for independent memory-reference

Find out the contents of registers PC, AR, DR, AC, and IR for two independent memory-reference instructions below. Each instruction starts with given Initial values.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd