You are employed by the NSA (National Security Agency) and you have received the following message that contains the following text: “George Smiley arrived in Prague on Friday evening at 10:50 PM. ……” See TTS.txt A quick analysis of text can be achieved by storing each word in a hash table. After storing all words in a hash table you will then be able to print all the words stored in each row of the hash table. Requirements: Create a hash key value (int Key) and init to a prime value (13) Create an array of string pointers S_ptr[13] Each string pointer, S_ptr[i], should allocate on the heap an array of strings (size 35) Initialize all row elements of hash table with ‘#’ Read the text, one word a time, and compute its hash index value (int Hash(string Word) The Hash function should take the numerical sum of all the characters in the Word and calculate (Sum%Key )which is then output to the program as an Index. Recognize that output Index can have only values ranging from(0-12) Store the word in the hash table row number obtained from the previous step (Index) Add the input Word into the next free element is the hash table row. The next free element is decided by finding the next ‘#’ value After storing all Words in the hash table, print the contents of all rows Print the total number of words in each row Sort (bubble sort) the words in each row and print again your results Provide some conclusions to this analysis tts.txt - "George Smiley arrived in Prague on Friday evening at 10:50 PM. As he left the train station he took a taxi to his hotel on Dvozak Boulevard. Next day, he arrived at noon to Café Kafka where he was supposed to meet agent Karla. Smiley sat at the far end of the café next to an empty round table. He placed his briefcase on the floor next to him while drinking his cafe noir. A few minutes past noon, Karla arrived at the cafe with the same looking briefcase and sat on the next table near Smiley. After placing his briefcase next to Smiley, he order a pint of ale and began browsing at the newspaper he took off the rack. A few minutes later, the waiter came to give Smiley his second cup of coffee and tripped creating a bit of a commotion. As this accident unfolded, Karla exchanged briefcases and returned the newspaper back to the rack next to him. Karla then quickly placed a few five Euro coins on the table and picked himself and dashed towards a Svoda taxi standing near the café. To the untrained eye, these events did not seem unusual. After some fifteen minutes later, Smiley paid his bill and went on to watch a magician do his tricks across the square # "
You are employed by the NSA (National Security Agency) and you have received the following message that contains the following text:
“George Smiley arrived in Prague on Friday evening at 10:50 PM. ……”
See TTS.txt
A quick analysis of text can be achieved by storing each word in a hash table. After storing all words in a hash table you will then be able to print all the words stored in each row of the hash table.
Requirements:
- Create a hash key value (int Key) and init to a prime value (13)
- Create an array of string pointers S_ptr[13]
- Each string pointer, S_ptr[i], should allocate on the heap an array of strings (size 35)
- Initialize all row elements of hash table with ‘#’
- Read the text, one word a time, and compute its hash index value (int Hash(string Word)
- The Hash function should take the numerical sum of all the characters in the Word and calculate (Sum%Key )which is then output to the program as an Index. Recognize that output Index can have only values ranging from(0-12)
- Store the word in the hash table row number obtained from the previous step (Index)
- Add the input Word into the next free element is the hash table row. The next free element is decided by finding the next ‘#’ value
- After storing all Words in the hash table, print the contents of all rows
- Print the total number of words in each row
- Sort (bubble sort) the words in each row and print again your results
- Provide some conclusions to this analysis
tts.txt -
"George Smiley arrived in Prague on Friday evening at 10:50 PM.
As he left the train station he took a taxi to his hotel on Dvozak Boulevard.
Next day, he arrived at noon to Café Kafka where he was supposed to meet agent Karla.
Smiley sat at the far end of the café next to an empty round table.
He placed his briefcase on the floor next to him while drinking his cafe noir.
A few minutes past noon, Karla arrived at the cafe with the same looking briefcase and sat on the next table near Smiley.
After placing his briefcase next to Smiley, he order a pint of ale and began browsing at the newspaper he took off the rack.
A few minutes later, the waiter came to give Smiley his second cup of coffee and tripped creating a bit of a commotion.
As this accident unfolded, Karla exchanged briefcases and returned the newspaper back to the rack next to him.
Karla then quickly placed a few five Euro coins on the table and picked himself and dashed towards a Svoda taxi standing near the café.
To the untrained eye, these events did not seem unusual.
After some fifteen minutes later, Smiley paid his bill and went on to watch a magician do his tricks across the square # "
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 4 images