Code problem huffman encoding

Assignment Help Basic Computer Science
Reference no: EM13741861

Code problem: Huffman encoding

Given a string s of length at most 104 over the alphabet of lower case latin letters. In the first line output the number k of different symbols and the length l of a binary encoding. In each of the next k lines output a binary code of a symbol in the form "<symbol>: <code>". In the last line output the encoded string. 

Sample Input 1:
a

Sample Output 1:
1 1
a: 0
0

Sample Input 2:
abacabad

Sample Output 2:
4 14
a: 0
b: 10
c: 110
d: 111
01001100100111

Memory Limit: 256 MB
Time Limit: 5 seconds

Huffman decoding

Given a Huffman encoding e of a string s output s.

The first line of the input contains the number k of different symbols in s and the length l of the encoding e of s. Each of the following k lines define a binary encoding of a symbol in the format "<symbol>: <code>". None of the codes is a prefix of another. The symbols are lower case latin letters. Each of the given k symbols appears in s. The last line of the input contains the encoding e. Output the string s. The length of s is at most 104.

Sample Input 1:
1 1
a: 0
0
Sample Output 1:
a

Sample Input 2:
4 14
a: 0
b: 10
c: 110
d: 111
01001100100111
Sample Output 2:
abacabad

Memory Limit: 256 MB
Time Limit: 5 seconds 

Reference no: EM13741861

Questions Cloud

Manufacturing involves taking a flat disc of silicon : Semiconductor manufacturing involves taking a flat disc of silicon, called a wafer, and depositing many layers of material on top of it. Each layer has a pattern on it that, upon completion, defines the electrical circuits of the finished microproces..
Data-hiding techniques : 1. Explain how a user could utilize ADS to hide data and explain other destructive uses which exist for ADS.2. Determine how rootkits can be used as an alternative for data hiding and explicate why they can be used for this purpose. 3. Describe the p..
Information about breast cancer : Conduct an Internet search for information about breast cancer. Find at least three sites with information on the topic. Print out the information obtained and critique the accuracy of the information
Well advised to pay for anyone to get a vaccination : Measles has become an epidemic here in Orange County. About 1 in 1000 people will die after contracting the disease. Because this is such a high rate, health officials in Orange County would be well advised to pay for anyone to get a vaccination.
Code problem huffman encoding : Given a string s of length at most 104 over the alphabet of lower case latin letters. In the first line output the number k of different symbols and the length l of a binary encoding. In each of the next k lines output a binary code of a symbol in th..
Suppose that for a firm that digs ditches for laying cable : Suppose that for a firm that digs ditches for laying cable or pipeline, backhoes and backhoe operators are pure complements in production, being used on a one-for-one basis. Draw the isoquants (on a graph with backhoe, “K”, and backhoe operators, “E”..
Explains effects of the disease on healthy body functions : Prepare report on Huntington's Disease. Explains effects of the disease on healthy body functions, and relates this to signs and symptoms
Linda who works for an intelligence company : Linda who works for an intelligence company is suspected of accessing and possessing digital content pertaining to turtles. Accessing, possessing, or distributing of digital content pertaining to turtles breaches both civil and criminal laws. Linda h..
Options on microsoft stock-disregarding option premium : Consider options on Microsoft stock. Suppose that there are call options with a strike price of $10 and put options with a strike price of $10, both with the expirations date of January 16th. Suppose that there is a 50% chance that the stock price wi..

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Can you name the country which contributed the video display

It had chips from Intel, disk drives from Tendon, operating system from Microsoft, the printer from Epson and the application software from everywhere.

  Write the sql query to return all of the information

Write the SQL query to return all of the information

  Study impact of global environmental policy

Consider how neighboring countries are affected, also emergent issues like new arctic shipping routes, or the international interest in Africa's natural resources. Study impact of global environmental policy associated with these issues.

  Evaluates and makes recommendations to address

Evaluates and makes recommendations to address differences in ethical codes of information technology conduct in different cultures in a very clear and detailed way.

  What are the primary components

What are the primary components that comprise an Oracle relational database management system? Identify at least 1 Bible verse that explains how we should facilitate relationships with each other. Expound upon this importance.

  Dos attacks exist for which part of the osi protocol stack

DoS attacks exist for which part of the OSI protocol stack?

  Discuss whether design considerations need to change

Are there certain projects in which the traditional approach would work better? If not, explain why not. If so, give at least one example of such a project.

  Maximum speedup-achieved by pipeline over non-pipelined unit

Non-pipelined system takes 200ns to process task. Determine the maximum speedup that could be achieved with pipeline unit over the non-pipelined unit?

  Explain how the web design department

Explain how the web design department will adhere to a code of ethics available for stakeholders.

  Benefits and three negative effects workplace automation

Write at least three benefits and three negative effects brought about by workplace automation. Multinational corporation transfers a foreign employee to the United States on an L-1 visa.

  Windows active directory

A research paper on Windows Active Directory and User Access Controls with some additional info about Group Policy Objects and Microsoft Baseline Security Analyzer.

  Wireless network design paper

Wireless Network Design Paper You will be designing a small wireless network for a small company, based on a given scenario. The scenario will include network assets (hardware and software), building diagrams, a list of users, and requirement ..

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