3)//returns max word length stored in trie
int maxWordLength(trienode* root){
if(root==NULL)
return 0;
int max=0;
for(int i=0;i<26;i++)
{
int k =
1+maxWordLength(root->next[i]);//calling all links through
recursion
if(max<k)
max=k;
}
return max;
}
3) (10 pts) Write a function that takes in a root node of a trie and...
1) (10 pts) Write a recursive function that counts and returns the number of nodes in a binary tree with the root root, that store an even value. Please use the struct shown and function prototype shown below. (For example, if the tree rooted at root stored 2, 3, 4, 8, 13, 18 and 20, the function should return 5, since there are five even values [2,4,8,18,20] stored in the tree. typedef struct node { int data; struct node* left;...
2) (10 pts) Write a function that takes in a pointer to a linked list of nodes storing integers and a variable named value, and returns the number of nodes in the list storing that value. For example, if a list pointed to by listPtr stores 2, 6, 2, 3, 4, 2, 6, and 6 and value = 6, your function should return 3, since 6 appears in the list 3 times. Please use the struct and function prototype provided...
Write a function int levelSearch(Node* root, int key) that takes as input the root node of a Binary Search tree and a key. The function searches the key in the BST and returns the level of the found node. If the key is not found in the tree, return -1. The level starts at 0 for the root node and increases from top to bottom. We have defined the following node C++ Node class for you: class Node { public: ...
Python3
Problem Write a function, height(root), that takes in the root node of a tree, and returns the height of the tree
. (4 points-Completeness) Implementing Multiway Trie Below is C++ node class defined as class MultiwayTrie f class Node public: public: bool word false; Node children [26]; Node ) Node* root new Node ) bool find(string word); void insert (string word); void remove (string word) Node: :Node (void) for (int i0 i 26: ++i) children [1] NULL; = (a)(e points-Completeness) Write the implementation of the insert of the MultiwayTrie class method below /Insert word into MultiwayTrie (return nothing) / void MultiwayTrie::insert...
In C++ 9) (5 pts) Complete the following function that takes 3 arguments of a circle : - radius (input argument) - area (output argument, to be calculated) - circumference (output argument, to be calculated) All arguments are double type. If a radius is negative, the function returns false, otherwise it returns true. The function does only calculation, and does nothing else. Assume that all #include are already there // Fill in your Function prototype bool circleAreaAndCircumference ( _______,...
Problem Statement This problem provides you with a linked list composed of node objects chained together via node pointers. Each node has a next pointer which points to the next node in the chain. The last node is identified by having a NULL (or nullptr) next pointer. The linked lists for this problem store string data. Your task: identify the longest string stored in the linked list. If two strings are of the same length, return the string that occurred...
Summary
You will write an application to build a tree structure called
Trie for a dictionary of English words, and use the Trie to
generate completion lists for string searches.
Trie Structure
A Trie is a general tree, in that each node can have
any number of children. It is used to store a dictionary
(list) of words that can be searched on,
in a manner that allows for efficient generation of completion
lists.
The word list is originally stored...
14. p contains the elements 66, 9, 14, 52, 87, 14 and 17, in that order. Consider running the following line of code: p = question4(p); where question4 is the function defined below. Show the contents of p after the function call. struct node* question4(struct node *list) { struct node* a = list; struct node* b = list; struct node* c; if (a == NULL) return NULL; while ( a->next != NULL) a = a ->next; a->next = b; c...
14. p contains the elements 66, 9, 14, 52, 87, 14 and 17, in that order. Consider running the following line of code: p = question4(p); where question4 is the function defined below. Show the contents of p after the function call. struct node* question4(struct node *list) { struct node* a = list; struct node* b = list; struct node* c; if (a == NULL) return NULL; while ( a->next != NULL) a = a ->next; a->next = b; c...