Implement a method to delete every node from your bst

Assignment Help Data Structure & Algorithms
Reference no: EM13315418

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
 
Optional: if you have time, implement a method to delete every node from your BST that contains a word that is 3 or fewer letters long (note that you must explicitly make these deletions, not fail to insert these words in the first place).

Reference no: EM13315418

Questions Cloud

What is the diameter d of the smallest-sized particles : In a hydrometer test, the data recorded at 60 minutes after the start of the test are as follows: Gs = 2.6, temperature of water T = 24°C and L = 9.2 cm. What is the diameter D of the smallest-sized particles
What is the phase constant of the other wave : Two sinusoidal waves of the same period, with amplitudes of 5.5 and 7.5 mm, travel in the same direction along a stretched string; What is the phase constant of the other wave
What fraction of the total energy is potential energy : When the displacement in SHM is 0.4 the amplitude A, what fraction of the total energy is kinetic energy, What fraction of the total energy is potential energy
Over what time interval does the proton reach this speed : A proton accelerates from rest in a uniform electric field of 625 N/C. At one later moment, its speed is 1.25E+06 m/s. Over what time interval does the proton reach this speed
Implement a method to delete every node from your bst : Implement a method to delete every node from your BST that contains a word that is 3 or fewer letters long (note that you must explicitly make these deletions, not fail to insert these words in the first place).
Human resources management - the key to strategic success : Define the concept of Human Resource Management (HRM) and discuss the contribution HRM makes to organisational success.
How many liters of water does the motor pump : A 2.2hp electric motor on a water well pumps water from 14m below the surface. How many liters of water does the motor pump in 2.0hr
How much work did this person do against gravity : A uniform 1.80m ladder of mass 6.30kg is leaning against a vertical wall while making an angle of 53.0%u2218 with the floor. How much work did this person do against gravity
Initial investment and problems in getting funded : Estimating the cash flow that might be emanating from the initial investment and problems in getting funded.

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Dbms and data mining to imporve customer service

Discuss how a database management system and data mining can help motor vehicle maintenance center improve its services, and what tables would be required in such a database.

  Algorithm-decide whether language recognized by dfa is empty

Give an algorithm to decide whether the language recognized by a DFA is empty. Given two DFAs M1 and M2, give an algorithm to decide whether L(M1)subset or equal to L(M2).

  Find minimum number of storage required for bfs and dfs

Assume we have problem space where there is uniform branching factor b and there is single goal node at depth m. Determine the minimum number of nodes expanded and storage required for BFS and DFS?

  Evaluate the average complexity of an enqueue operation

Evaluate the average complexity of an enqueue operation. Determine the average complexity of the dequeue (remove) operation.

  What-if and goal-seeking analysis

Problem 1: What-if and Goal-seeking analysis, Problem 2: Portfolio Planning using optimization, Problem 3: A Monte Carlo Simulation Problem

  Implement bucket sort suing two-dimensional array

Where n is number of values to be sorted. Each row of two-dimensional array is referred to as bucket. Write class named BucketSort containing method called sort.

  Explain the sorting techniques selection sort

Explain the following sorting techniques using appropriate algorithms- (i) selection sort (ii) bubble sort

  Determine the values for m and l for the b+ tree

A B+-tree is to be stored on disk whose block size is 2048 bytes. The data records to be stored are 50 bytes, and their key is 4 bytes. Determine the values for M and L for the B+-tree. Assume pointers are 4 bytes each.

  Implement a queue as a circular array

Implement a queue as a circular array as follows: Use two index variables head and tail that contain the index of the next element to be removed and the next element to be added.

  How is a pert chart useful?

How is a Pert chart useful? How is a Gantt chart useful? What are the differences and similarities between both?

  How to access virtualised applications through unicore

How to access virtualised applications through UNICORE

  Using channel to implement the back up

Think about an organization, which has a rented communications channel in two buildings, building A and building B. They have a set of servers in building A,

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