The aim is to save the words in a given text file (.txt) in the tree structure given below and speed up the search. After parsing each word in the text file, both the word itself and the line number of the words in the text will be recorded in the tree. Below is an example of what to do. It will be accepted that the following sentence is in the first line of the text. This is the first sentence of the text and you can write whatever you want in the (.txt) file, my dear experts. “There are cups in a bin with binary bits on them kept in a cupboard" Create the above tree structure. The nodes of the tree are indicated by circles. Each node contains a character and a reference to a link list. Whether there is an element in the link list depends on whether that node is the last letter of a word in the text. More explanations are available below. Each word in the text is located on a path in the tree. The word is sometimes found at the leaf nodes, sometimes it is located before it reaches the leaf. Examples of words on the leaf are "cupboard", "cups" and "binary". Examples of words formed before reaching the leaf are only the words "a" and "bin". An arrow and a box are placed at the nodes where the end of the words is located. The arrow and the following box from these nodes represent a linked list. Each element of the linked list represents the line in which this word occurs in the text. There can be more than one element in a linked list, as words can be found on different lines. For example, if we accept that the word "cupboard" occurs on lines 1, 3 and 12, the linked list linked to the letter "d" above should be as follows: If you pay attention, it can be seen that the linked list only depends on the last letters of the words in the text. Although it is in the dictionary, some words are not included in the text, so they are not accepted as words in the tree above. For example, although the words "cup", "the" and "wit" are in the English dictionary, they are not included as words in the tree above (because there is no linked list after the letters "p", "e" and "t"). When the tree is examined, it will be seen that the siblings are added as nodes in alphabetical order to speed up the search. After the above tree structure is created, the user should be given the opportunity to search. For example, when the user searches for the word "cup", it should not be found, but should be found with the word "cups" (by browsing the tree structure). If found, the lines that are passed should be reported to the user. This code should have "strtok" function, it will parse words! No "binary search tree" or "binary tree" will be used in this question. Other than "right" and "left", other things will be needed.
Urgent! It's just a question and explained in detail.
I need expert help on this question. I can't solve the question and I keep making mistakes.
C language, tree and list structure will be used.
The aim is to save the words in a given text file (.txt) in the tree structure given below and speed up the search. After parsing each word in the text file, both the word itself and the line number of the words in the text will be recorded in the tree.
Below is an example of what to do.
It will be accepted that the following sentence is in the first line of the text. This is the first sentence of the text and you can write whatever you want in the (.txt) file, my dear experts.
“There are cups in a bin with binary bits on them kept in a cupboard"
Create the above tree structure.
The nodes of the tree are indicated by circles. Each node contains a character and a reference to a link list. Whether there is an element in the link list depends on whether that node is the last letter of a word in the text. More explanations are available below.
Each word in the text is located on a path in the tree. The word is sometimes found at the leaf nodes, sometimes it is located before it reaches the leaf.
Examples of words on the leaf are "cupboard", "cups" and "binary".
Examples of words formed before reaching the leaf are only the words "a" and "bin".
An arrow and a box are placed at the nodes where the end of the words is located. The arrow and the following box from these nodes represent a linked list. Each element of the linked list represents the line in which this word occurs in the text. There can be more than one element in a linked list, as words can be found on different lines. For example, if we accept that the word "cupboard" occurs on lines 1, 3 and 12, the linked list linked to the letter "d" above should be as follows:
If you pay attention, it can be seen that the linked list only depends on the last letters of the words in the text.
Although it is in the dictionary, some words are not included in the text, so they are not accepted as words in the tree above. For example, although the words "cup", "the" and "wit" are in the English dictionary, they are not included as words in the tree above (because there is no linked list after the letters "p", "e" and "t").
When the tree is examined, it will be seen that the siblings are added as nodes in alphabetical order to speed up the search.
After the above tree structure is created, the user should be given the opportunity to search. For example, when the user searches for the word "cup", it should not be found, but should be found with the word "cups" (by browsing the tree structure). If found, the lines that are passed should be reported to the user.
This code should have "strtok" function, it will parse words!
No "binary search tree" or "binary tree" will be used in this question. Other than "right" and "left", other things will be needed.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps