Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

void Decompress(const char* _outputFile) { // TODO: // 1. Create a BitIfStream and read the frequency table BitIfstream bitIfStream(mFileName.c_str(), (char*)mFrequencyTable, 256); // 2. Create the

void Decompress(const char* _outputFile) { // TODO: // 1. Create a BitIfStream and read the frequency table BitIfstream bitIfStream(mFileName.c_str(), (char*)mFrequencyTable, 256); // 2. Create the leaf list and tree (in this order) GenerateLeafList(); GenerateTree(); // 3. Create a standard ofstream for output (binary mode) std::ofstream outputFile(_outputFile, std::ios_base::binary); // 4. Create a bool to use for traversing down the list, and a char to store the character for writing bool bitValue; char outputChar; // 5. Create a node pointer for use in traversing the list (start it at the top) HuffNode* point = mRoot; // 6. Go through the compressed file one bit at a time, traversing through the tree // When you get to a leaf node, write out the value, and go back to the root // Note: Remember, there may be trailing 0's at the end of the file, so only loop the appropriate number of times while (bitIfStream.Read(bitValue)) { if (bitValue) { point = point->right; } else { point = point->left; } if (point->IsLeaf) { outputChar = point->value; outputFile.put(outputChar); point = mRoot; } } // 7. Close the streams bitIfStream.Close(); outputFile.close(); // 8. Clean up the dynamic memory by clearing the tree ClearTree(); }

For question 6 I get two errors. The .Read and the IsLeaf are the ones shooting the errors

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals, Design, and Implementation

Authors: David M. Kroenke, David J. Auer

14th edition

133876705, 9781292107639, 1292107634, 978-0133876703

More Books

Students also viewed these Databases questions

Question

The paleolithic age human life, short write up ?

Answered: 1 week ago

Question

5. What are the main groups without health insurance? LO24.3

Answered: 1 week ago