In this assignment you are to write a program that analyzes

Assignment Help Data Structure & Algorithms
Reference no: EM13379914

In this assignment, you are to write a program that analyzes a selection of text, counting the number of times each word appears in the text. Your word counts must ignore capitalization, so the, The, THE, and tHe all increase the count for the word "the" by one. For purposes of this assignment, a word is any consecutive string of letters and the apostrophe character, so don't counts as a single word, and best-selling counts as two words: best and selling. Notice that a blank space will not necessarily occur between two words. Numbers such as 27 and 2/3 will NOT be counted as words.

You must store the words and the counts of the words in a single binary search tree. Each word occurring in the text can only be stored once in the tree. Call the structure for the nodes of the tree WordNode, and call the references in this structure left and right. Use Strings to store words in the tree. Call the class implementing the binary search tree WordTree. It must contain the following public methods:

- constructors
- add: adds the given word to the tree if it is not already in the tree OR increments the appropriate counter if it is already there. It returns nothing.
- countNodes: returns the number of words currently stored in the tree.
- countWordsWith4Chars: returns the number of words which have exactly four characters.
- print: display the words of the tree in alphabetical order, and next to each word, prints the number of times each word occurs in the text.

Three of these operations (all but add) must visit every node in the tree. One of these must use preorder traversal, one must use inorder traversal, and one must use postorder traversal. You must decide which to use for each method, but use comments to document the type of traversal used.

The WordTree class may have only one data member variable, root, and it must be private.

Your program should perform the following steps:

1. Prompt the user for the name of the file (a string). Use the string input by the user as an argument to open file:

2. Open the file on disk, and process its contents, adding unique words to the BST and increasing the counts of existing words if necessary

3. Repeat steps 1&2 until the user enters some sentinel value.

4. Print out the total number of nodes in your tree

5. Print out the number of words which have exactly four characters.

6. print out the contents of a tree in alphabetical order

Reference no: EM13379914

Questions Cloud

Write a c program that will calculate the gross pay of a : write a c program that will calculate the gross pay of a set of employees.for each employee the program should prompt
Security in bluetooth and other mobile devicesbefore : security in bluetooth and other mobile devicesbefore supporting mobile and wireless devices organizations need to
Suppose that a vector processor has a memory system in : suppose that a vector processor has a memory system in which it takes 10 cycles to load a single 64-bit word from
Consider any of the supercomputing examples we discussed in : consider any of the supercomputing examples we discussed in class and find a scientific paper describing it. you must
In this assignment you are to write a program that analyzes : in this assignment you are to write a program that analyzes a selection of text counting the number of times each word
In this assignment you will write a program that does : in this assignment you will write a program that does simple packet routing. your program will take three command-line
1 write an algorithm that converts a linear measurement in : 1. write an algorithm that converts a linear measurement in feet and inches into meters. one inch is equivalent to 2.54
1 give an example to show that the group of permutations s5 : 1. give an example to show that the group of permutations s5 is not commutative.2. use ecb mode with block length 3 and
1 write a c program to display the following sum4 812162024 : 1. write a c program to display the following sum4 812162024 ...4042. write a program that will convert us dollar

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Find capacity of a particular airplane type

Consider the entities and their attributes. You should 1st determine what entities want to track. Next determine what attributes are required for each entity, and what relations exist between these entities.

  Object oriented approach versus the relational database

Supporters of object oriented databases list many benefits for using the object oriented approach versus the relational one.

  Creating flowchart to compute and print the total sale

A coorporation's salesman are selling toothpaste and tooth powder. The corporation having fifty salesman gives 10% commission on the sale of toothpaste and 20 percent commission on tooth powder.

  Write down the output values and number of instances

Write down the output (class) values and number of instances that appear in each of the leaf nodes A, B and C of the tree.

  Design a gui and implement tic tac toe game in java

Design a GUI and implement Tic Tac Toe game in java

  How space efficient is your hamming code

Construct a specific error in more than this number of bits and explicitly show that the Hamming algorithm fails to detect the error. How space (number of bits required) efficient is your Hamming code?

  Hash values

Suppose these names have the following hash values. Insert them into the extendible hash table shown below. Each leaf can only hold 4 entries.

  Show the postfix expressions

An infix expression is one in which operators are located between their operands - Pop the stack elements and add them to the queue (PostQueue) one by one until the top of the stack has an element of lower precedence

  Draw the human encoding tree of these six characters

Show how to nd the maximum spanning tree of a graph, that is, the spanning tree of largest total weight.

  Illustrate insertion into the linear hash file

Illustrate insertion into the linear hash file. Suppose that bucket splitting occurs whenever file load factor exceeds (is greater than) 0.8.

  Give the steps to build priority queue in heap structure

Both are given from a paper assignment both are Logic questions. I don't need ANY CODE AT ALL. Just the general steps you would use.

  Quicksort will result in quadratic behavior

Describe a case where quicksort will result in quadratic behavior.

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