Question: Exercise 1 Text Tree In this assignment you will create a tree that can store sentences. Each node stores a single word and may have

 Exercise 1 Text Tree In this assignment you will create a

tree that can store sentences. Each node stores a single word and

Exercise 1 Text Tree In this assignment you will create a tree that can store sentences. Each node stores a single word and may have 0 to N child nodes. The root node is empty and does not store any value. The add(.) method accepts a single sentence as String and breaks it up into words at each space. These words are then inserted into the tree such that they define a path starting at level 2. There is no limit to the number of levels a tree can have. In more detail: The method add(.) splits the sentence up by space into N words. These words are then inserted into the tree consisting of potentially existing nodes and newly created nodes. That is, the algorithm will match a node's value at level 1 to word 0, then match a child of the existing node to word 1, etc. until no match is found. At this point, new nodes are created as a descendant path for each following word in the sentence a word in this case consists of any characters other than space and may include symbols Example Insertion of "Good Morning!", "Good Night!", "Today is Wednesday!", "Today is Thursday!", "Today, it's raining. " will result in the following tree: Today, Good Today it's Morning! Night! is Wednesday. Thursday raining

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!