Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Huffman Encoding and our BST This will be a multipart assignment The first part will be analyzing a section of a text and determining

C++ Huffman Encoding and our BST This will be a multipart assignment

The first part will be analyzing a section of a text and determining letter frequency. For our purposes we will ignore case, spaces and punctuation. (Look at toupper and tolower for an easy way to change letters to either case.) The second part is to create a class that can hold the letter, and the frequency. The third part involves add your data to a BST. Read in a text file character by character. You can use isalpha and toupper for testing the characters you read in. Update the character count. I used an array of my class. After you finish reading the file and the counts are updated, add the instances of the class to your BST. Use frequency order for the insert. Do not change the BST class. Use the various traversals and see if you can construct the tree (by hand is okay) that you come up with. Be sure to test with just a few letters to make sure everything works before you try the text supplied This won't give a true Huffman code but we can begin to see how the process works. Here's a sample of what counts (this is not the text I'm providing.) Heres a sample of what counts (this is not the text Im providing.) 708 515 487 449 448 441 388 368 331 239 225 203 201 181 146 138 126 125 95 61 56 50 1 10 7 7 m7

Text files are given below: input.txt, input2.txt and input4.txt For a nice write-up on Huffman checkout: http://www.cprogramming.com/tutorial/computersciencetheory/huffman.html

input.txt

The Fall of the House of Usher Son coeur est un luth suspendu; Sitot qu'on le touche il resonne. DE BERANGER. During the whole of a dull, dark, and soundless day in the autumn of the year, when the clouds hung oppressively low in the heavens, I had been passing alone, on horseback, through a singularly dreary tract of country; and at length found myself, as the shades of the evening drew on, within view of the melancholy House of Usher.

input2.txt It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way-- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

input4.txt It is a truth universally acknowledged, that a single man in possession of a good fortune, must be in want of a wife. However little known the feelings or views of such a man may be on his first entering a neighbourhood, this truth is so well fixed in the minds of the surrounding families, that he is considered the rightful property of some one or other of their daughters. "My dear Mr. Bennet," said his lady to him one day, "have you heard that Netherfield Park is let at last?" Mr. Bennet replied that he had not. "But it is," returned she; "for Mrs. Long has just been here, and she told me all about it." Mr. Bennet made no answer. "Do you not want to know who has taken it?" cried his wife impatiently. "_You_ want to tell me, and I have no objection to hearing it." This was invitation enough.

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 Programming Languages 12th International Symposium Dbpl 2009 Lyon France August 2009 Proceedings Lncs 5708

Authors: Philippa Gardner ,Floris Geerts

2009th Edition

3642037925, 978-3642037924

More Books

Students also viewed these Databases questions

Question

Determine z0.33.

Answered: 1 week ago

Question

1 import math def median(arr): Finds a median." n = len(arr) if n

Answered: 1 week ago

Question

2. Ask questions, listen rather than attempt to persuade.

Answered: 1 week ago