Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started