Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Explain the aswer please. a The word intention is such that four of its prefixes, 4, in, intent and intention themselves. Write a function that
Explain the aswer please.
a The word intention is such that four of its prefixes, 4, in, intent and intention themselves. Write a function that takes in a pointer to the root of a trie storing a dictionary returns the maximum number of words that are prefixes of a single word. Use the struct d function prototype given below. typedef struct TrieNode { struct TrieNode *children [26]; int flag; // 1 if the string is in the trie, o otherwise } TrieNode; int max (int a, int b) { if (a > b) return a; return b; } int maxNumPrefixWords (TrieNode* root) { if (root == NULL) return 0; // 2 pts int maxChild = 0; int i; for (i=0; ichildren[i])); // 4 pts, 3 pts for rec call, 1 for updating max return maxChild + root->flag; // 2 ptsStep 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