Question

Construct the Hoffman code for the C++ keywords given below for which the expected length of the bit string for each keyword

Answer: Write the Hoffman codes for all the words Weights Hoffman Code Words float 35 int 3 while .1 switch .1 for .1 if 05

0 0
Add a comment Improve this question Transcribed image text
Answer #1

sorted weight order words weights: word 05 while switch lor 0.1 int float 35 if 0.05 0.15 while ool 0.35 Switch o. l 0.2 for

Huffman Tree (1.00 float: 0.35) 0.65 int: 0.3 0.15 0.2 Switch :0. weight code 0.35 o 0.3 ő 0: 1101 0.) 1110 0.1 0.05 1100

Add a comment
Know the answer?
Add Answer to:
Construct the Hoffman code for the C++ keywords given below for which the expected length of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • [Python] Construct Tree Using Inorder and Preorder Given Preorder and Inorder traversal of a binary tree,...

    [Python] Construct Tree Using Inorder and Preorder Given Preorder and Inorder traversal of a binary tree, create the binary tree associated with the traversals.You just need to construct the tree and return the root. Note: Assume binary tree contains only unique elements. Input format : Line 1 : n (Total number of nodes in binary tree) Line 2 : Pre order traversal Line 3 : Inorder Traversal Output Format : Elements are printed level wise, each level in new line...

  • Here is the code I made, but the test case is not working, it goes wrong...

    Here is the code I made, but the test case is not working, it goes wrong when the binary string convert to decimal. please help. #include "stdafx.h" #include <iostream> #include <string> #include <math.h> #include <locale> using namespace std; // function for option 1 void decToBin(int number) {        int array[16];        int i = 0;        for (int counter = 0; counter < 16; counter++)        {               array[counter] = 0;        }        while (number > 0)        {...

  • You will construct a Huffman tree based on the given frequencies of 26 English alphabets in...

    You will construct a Huffman tree based on the given frequencies of 26 English alphabets in upper case plus the space character. An internal tree node class in HuffmanTree with necessary information is required. • You will not randomly switch left and right children when merger two trees. Instead, you will build a right-heavy tree according to the following strategies to select the right child. (1) The tree that is taller will be the right child, i.e., the height is...

  • (b.) Huffman code is a way to encode information using variable-length binary strings to represent symbols depending on the frequency of each individual letter. Specifically, letters that appear more...

    (b.) Huffman code is a way to encode information using variable-length binary strings to represent symbols depending on the frequency of each individual letter. Specifically, letters that appear more frequently can be encoded into strings of shorter lengths, while rarer letters can be turned into longer binary strings. On average, Huffman code is a more efficient way to encode a message as the number of bits in the output string will be shorter than if a fixed-length code was used....

  • in c++ please program for this code #include <iostream> #include <fstream> #include <string> #include <cstring> //...

    in c++ please program for this code #include <iostream> #include <fstream> #include <string> #include <cstring> // for string tokenizer and c-style string processing #include <algorithm> // max function #include <stdlib.h> #include <time.h> using namespace std; // Extend the code here as needed class BTNode{ private: int nodeid; int data; int levelNum; BTNode* leftChildPtr; BTNode* rightChildPtr; public: BTNode(){} void setNodeId(int id){ nodeid = id; } int getNodeId(){ return nodeid; } void setData(int d){ data = d; } int getData(){ return data;...

  • For this assignment, you will write a program to work with Huffman encoding. Huffman code is...

    For this assignment, you will write a program to work with Huffman encoding. Huffman code is an optimal prefix code, which means no code is the prefix of another code. Most of the code is included. You will need to extend the code to complete three additional methods. In particular, code to actually build the Huffman tree is provided. It uses a data file containing the frequency of occurrence of characters. You will write the following three methods in the...

  • C++ / Visual Studio Implement the member function below that returns true if the given value...

    C++ / Visual Studio Implement the member function below that returns true if the given value is in the container, and false if not. Your code should use iterators so it works with any type of container and data. template< typename Value, class Container > bool member( const Value& val, const Container& cont ); just implement this function in the code below #include <iostream> #include <array> #include <deque> #include <list> #include <set> #include <string> #include <vector> using namespace std; #define...

  • . Huffman Encoding (a.) (6 points) Suppose a certain file contains only the following letters with the corresponding frequencies 1 AİB 73 9 30 44 130 28 16 In a fixed-length encoding scheme, cach...

    . Huffman Encoding (a.) (6 points) Suppose a certain file contains only the following letters with the corresponding frequencies 1 AİB 73 9 30 44 130 28 16 In a fixed-length encoding scheme, cach character is given a binary representation with the same number of bits. What is the minimum number of bits required to represent each letter of this file under fixed-length encoding scheme? Describe how to encode all seven letters in this file using the number of bits...

  • *** Please construct a flowchart for the following code (this was in C++): *** #include using...

    *** Please construct a flowchart for the following code (this was in C++): *** #include using namespace std; void printPrompt(int n){    switch(n){        case 1:            cout << "Enter the quiz grades:" <            break;        case 2:            cout << "Enter the assignments grades:" <            break;        case 3:            cout << "Enter the exam grades:" <            break;        case...

  • Predictors Given the following piece of code below, compute the accuracies of the 1 bit and...

    Predictors Given the following piece of code below, compute the accuracies of the 1 bit and 2 bit predictors. Assume that the branch is taken if the "if" condition is met. The 1 bit predictor is initialized to 1 and the 2 bit predictor is initialized to 10. i-0; do1 if (i%2--?) { #Branch 1 if (i%2-1){ #Branch 2 }while (i<10000); #Branch 3 1 bit 2 bit Branch 1 Branch 2 Branch 3

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT