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

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

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