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

  What strategies implement in terms of career development

What strategies you will implement in terms of your career development. How these strategies specifically relate to your career goals and advancement.

  Create method that prints a rectangle of characters console

Create a method that prints a rectangle of characters to the console. The method should use a character set that parameter to the method.

  We will compare the performance of a vector processor

In this problem, we will compare the performance of a vector processor with a hybrid system that contains a scalar processor and a GPU-based coprocessor.

  The code be written by hand using a text editor

Demonstrate your ability to create a web site. Your web site should consist of at least 4 pages, a main page, an additional information page, a page containing form elements (such as a contact page), and one additional page of your choice.

  Use of visitor pattern to supply additional functionality

Rather than use the Visitor pattern to supply additional functionality. Give the details and compare the advantages and disadvantages of this approach when compared to the Visitor pattern.

  Floating point format has an n-bit frac field

Suppose a floating point format has an n-bit frac field and a k bit exp field. What is the smallest integer that can be represented exactly? Assume that k is large enough not to provide any limitations on the problem. What is the integer for IEEE-754..

  Write a program to manage a dictionary

Then ask whether the user wants to add this new word to the dictionary. If the answer is yes, do so and go back to request the next word.

  What does this value indicate

The value of the Destination Address in a given Ethernet frame contains ff:ff:ff:ff:ff:ff. What does this value indicate

  An enterprise architecture (ea) framework uses multiple view

An enterprise architecture (EA) framework uses multiple views when planning and documenting infrastructures. It does not just concentrate on hardware. These views support entire system life cycles. With a focus on networking, research on archit..

  Visit the web sites of the major technology organizations

Visit the Web sites of the major technology organizations

  Use free or open source

Use free or open source.

  Find the average case complexity of sequential search

Find the average case complexity of sequential search in an array if the probability of accessing the last cell equals 1/2, the probability of the next to the last cell equals 1/4 .

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