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>>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(); }

I follow the instruction and no I got another two errors for question 6.

here are the two errors

Severity Code Description Project File Line Suppression State Error (active) E0711 expression must have bool type (or be convertible to bool) DSA Labs C:\Users\donni\OneDrive\Desktop\DSA2\DSA Labs\DSA Labs\Huffman.h 324 Severity Code Description Project File Line Suppression State Error (active) E0135 class "Huffman::HuffNode" has no member "IsLeaf" DSA Labs C:\Users\donni\OneDrive\Desktop\DSA2\DSA Labs\DSA Labs\Huffman.h 334 Here is the heeder for the bitStream

class BitIfstream {

std::ifstream mStream; // The stream to use for inputting char mBuffer; // The current byte to read int mBitIndex; // The current bit in the buffer to read

public:

// Constructor // Will open the file and read the header (if there is one) // // In: _fileName The name of the file to open for input // _fileHeader Where to store the file header (OPTIONAL) // _headerSize The number of bytes in the optional header (OPTIONAL) BitIfstream(const char* _fileName, char* _fileHeader = nullptr, unsigned int _headerSize = 0);

// Destructor // Will close the file ~BitIfstream();

// Extraction operator // Sends back one bit from the buffer. Will read another char into the buffer once all // bits have been processed. // // In: _bit Where to store the bit // // Return: The invoking object // This allows extractions to be daisy-chained (standard behavior) BitIfstream& operator>>(bool& _bit);

// Check for End of File // // Return: True, if we are at the end of the file, having read every byte from the file and processed every bit bool eof();

// Close the file void Close();

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 Systems An Application Oriented Approach Complete Version

Authors: Michael Kifer, Arthur Bernstein, Richard Lewis

2nd Edition

0321268458, 978-0321268457

More Books

Students also viewed these Databases questions

Question

What are the stages of project management? Write it in items.

Answered: 1 week ago

Question

why do consumers often fail to seek out higher yields on deposits ?

Answered: 1 week ago

Question

=+1 What would you do if you were the IHR manager?

Answered: 1 week ago