Description in the last episode of the mafghanistan trilogy

Assignment Help Computer Engineering
Reference no: EM13360847

Description: In the last episode of the Mafghanistan trilogy, the Mamerican forces invaded liberated Mafghanistan in pursuit of mineral freedom. However, terrorist attacks spread across Mafghanistan like the oil spill from the Deepwater Horizon. You, as the Commanding General of the Mamerican forces and their Mafghan puppets allies, just discovered the book, which describes efficient algorithms for terminating insurgents, that would ensure victory in Mafghanistan. You wish to send this book to all the troops via the Internet ASAP. However, due to the astronomical deficit of the Mamerican government, you wish to compress the book to reduce your ISP charges.

Use Huffman coding for compression/decompression.

The input to compression is a sequence of 8-bit characters.

When computing the Huffman tree, do not compute the code for any character that does not exist in the input. Do not insert these characters into the min-heap.

To ensure consistent behavior between your program and mine, during the delete operation on the min-heap, you need to determine the priority of the subtrees that have the same weight. Let S and T be two subtrees. S has a higher priority than T if and only if:

S's weight is smaller than T's weight, or

S and T have the same weight, and the smallest character (in ASCII value) in any of S's leaf nodes is smaller than that in any of T's leaf nodes.

Under this definition, the delete operation should remove the subtree with the highest priority from the min-heap. Also when merging two subtrees, set the tree with the lower priority as the left subtree (whose code is 0), and the tree with the higher priority as the right subtree (whose code is 1).

You may NOT use STL classes except the string class.

Command line: Your program accepts an optional command line argument "-d":

When this argument is absent, compress the input and writes the compressed data to the output.

When this argument is present, decompress the input and writes the decompressed data to the output.

Read input from cin and write output to cout.

Uncompressed data: The uncompressed data contains a sequence of 8-bit characters. The input contains at most 232-1 characters.

Compressed data: The compressed data contains three sections:

Magic cookie. This section contains 8 characters: the string "HUFFMA5" followed by the ASCII 0 character ('\0').

Frequencies. This section contains the frequencies of all the characters from ASCII 0 to ASCII 255, even if a characer is absent from the uncompressed data. The frequency of a character is its count in the uncompressed data. Order the frequencies by the ASCII values of their corresponding characters. Write each frequency as a 4-byte unsigned integer in the little-endian form.

Compressed data. This section contains the codes of all the characters in the same order as they appear in the uncompressed data. Since this section contains a sequence of bits but the smallest unit of data is a byte in files, you need to convert bits into bytes by the following rules:

Starting from the beginning of the bit sequence, convert each sequence of 8 consecutive bits into 1 byte. If the number of bits is not a multiple of 8, pad the end of the bit sequence with 0s.

When converting 8 bits into 1 byte, let the first bit be the least significant bit (LSB) in the byte, the second bit be the second LSB, and so on.

We will test the decompression function of your program with only valid compressed data, so your program need not handle errors in the compressed data.

Reference no: EM13360847

Questions Cloud

Execution stage of project management1 as the project : execution stage of project management1. as the project manager whose project is now in the execution stage briefly
Healthcare planning and marketingcourse : healthcare planning and marketingcourse descriptiondiscusses and applies the concepts of healthcare planning and
Understanding and managing conflitin the managing conflict : understanding and managing conflitin the managing conflict in organizations social conflict is informed by various
Five organizational structures1 compare and contrast each : five organizational structures1. compare and contrast each of the five organizational structures functional divisional
Description in the last episode of the mafghanistan trilogy : description in the last episode of the mafghanistan trilogy the mamerican forces invaded liberated mafghanistan in
Managing groups and teams in gaminghow can coevolutionary : managing groups and teams in gaminghow can coevolutionary gaming facilitate group decision-making?what are its
Suggested skills for project managerswhat are suggested : suggested skills for project managerswhat are suggested skills for all project managers and why it is important to
Techniques to resolve conflictshow the following techniques : techniques to resolve conflictshow the following techniques that help resolve conflicts among people or teams vision
Staffing management planwhat is the purpose of a staffing : staffing management planwhat is the purpose of a staffing management plan? what factors must be considered when

Reviews

Write a Review

Computer Engineering Questions & Answers

  Studying the relational database

On the basis of this relational database; provide an expression in the relational algebra in order to express each of following queries: Determine the names of all students who have GPA greater than 3.

  Create a text file called scores.txt with notepad

Create a text file called scores.txt with notepad with two lines: the first two lines are the computer scores and the second line human scores.

  Find minimal cover and identify all possible candidate keys

Find minimal cover and identify all possible candidate keys - Functional Dependencies

  Program for translates letter grade into number grade

Write down a program which translates the letter grade into number grade.

  What is mno

What is MNO.

  Design the program in vb.net

Write down the program in VB.Net (not Web based) and have it accept user input of the amount, term and interest rate. Display the mortgage payment amount.

  Question1 define defense in depth and explain the different

question1. define defense in depth and explain the different layers.2. what is leading security principle in

  Create a .plan file using pico/nano

Create a .plan file using PICO/NANO

  Benefits of the two computer programmers

A multinational corporation transfers the foreign employee to the United States on a L-1 visa. The foreign employee is a computer programmer, working alongside an American computer programmer doing the equal  work.

  Make two alternative design strategies

Describe two alternative design strategies, and explain how each would meet the requirements. What are the constraints in this situation.

  How many bits are required to reference a page frame

A system has a virtual memory space of 8 virtual pages for a process with 4 blocks per page and 8 words per block. The main memory consists of 32 page frames with 4 blocks per page and 8 words per block. How many bits are required to reference a p..

  Questionplan a payroll class that has data members for an

questionplan a payroll class that has data members for an employees hourly pay rate and number of hours worked.

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