Question: Kindly do file handing in the given code C++ please do file handing and make changes in the given code The program should read words

Kindly do file handing in the given code C++

please do file handing and make changes in the given code

The program should read words from the txt file.

The given code: C++ language

#include #include #include

using namespace std; struct node { int level; int key; char value; bool valid; vector children; node(){} };

class trie { public: node *root; int count; string *array;

trie(int size) { root=new node(); root->level=0; root->valid=0; root->key=0; array=new string[size]; count=0; }

void insert(string word) { node *parent=root; while(parent->level temp; while(!parent->children.empty()){ if(parent->children.back()->value==word[parent->children.back()->level-1]) { node *tNew=parent->children.back(); while(!temp.empty()){ parent->children.push_back(temp.back()); temp.pop_back(); } parent=tNew; } else { temp.push_back(parent->children.back()); parent->children.pop_back(); } } if(parent->level==word.length()) { if(parent->valid==0) { parent->valid=1; parent->key=count; array[count]=word; count++; } while(!temp.empty()) { parent->children.push_back(temp.back()); temp.pop_back(); } break; } else { node *newNode=new node(); newNode->level=parent->level+1; newNode->value=word[newNode->level-1]; newNode->valid=0; if(newNode->level==word.length()){ newNode->valid=1; newNode->key=count; array[count]=word; count++; } while(!temp.empty()) { parent->children.push_back(temp.back()); temp.pop_back(); } parent->children.push_back(newNode); parent=newNode; } } }

node*search(string str) { node *parent=root; while(parent->level temp; while(!parent->children.empty()) { if(parent->children.back()->value==str[parent->children.back()->level-1]) { node *tNew=parent->children.back(); while(!temp.empty()){ parent->children.push_back(temp.back()); temp.pop_back(); } parent=tNew; break; } else { temp.push_back(parent->children.back()); parent->children.pop_back(); } } } return parent; } void wordSuggestions(string str) { node *parent = search(str); vector suggestions; vector immediateChilds; vector allChilds; while(!parent->children.empty()) { immediateChilds.push_back(parent->children.back()); if (parent->children.back()->valid==1){ suggestions.push_back(array[parent->children.back()->key]); } parent->children.pop_back(); if(parent->children.empty()){ parent->children=immediateChilds; while(!immediateChilds.empty()) { allChilds.push_back(immediateChilds.back()); immediateChilds.pop_back(); } parent=allChilds.back(); allChilds.pop_back(); } while(parent->children.empty() && !allChilds.empty()) { parent=allChilds.back(); allChilds.pop_back(); } } while(!suggestions.empty()){ cout

};

int main() {

//cout

return 0; }

The given txt file:

Kindly do file handing in the given code C++ please do file

A- prefix (also an- before a vowel sound) not, without (amoral). [greek] Aa abbr. 1 automobile association. 2 alcoholics anonymous. 3 anti-aircraft. Aardvark n. Mammal with a tubular snout and a long tongue, feeding on termites. [afrikaans] Ab- prefix off, away, from (abduct). [latin] Aback adv. I take aback surprise, disconcert. [old english: related to *a2] Abacus n. (pl. -cuses) 1 frame with wires along which beads are slid for calculating. 2 archit. Flat slab on top of a capital. [latin from greek from hebrew abaft naut. -adv. In the stern half of a ship. -prep. Nearer the stern than. [from *a2, -baft: see *aft] Abandon -v. 1 give up. 2 forsake, desert. 3 (often foll. By to; often refl.) Yield to a passion, another's control, etc. -n. Freedom from inhibitions. I abar Abandoned adj. 1 deserted, forsaken. 2 unrestrained, profligate. Abase v. (-sing) (also refl.) Humiliate, degrade. I abasement n. [french: related to *ad-, *base2] Abashed predic. Adj. Embarrassed, disconcerted. [french es- *ex-1, bar astound] Abate v. (-ting) make or become less strong etc.; diminish. I abatement n. [french abatre from latin batt(u)o beat] Abattoir n. Slaughterhouse. [french abatre fell, as *abate] Abbacy n. (pl. -ies) office or jurisdiction of an abbot or abbess. [latin: related to *abbot] Abb n. (in france) abbot or priest. [french from latin: related to *abbot] Abbess n. Head of a community of nuns. Abbey n. (pl.-s) 1 building(s) occupied by a community of monks or nuns. 2 the community itself. 3 building that was once an abbey. Abbot n. Head of a community of monks. [old english from latin abbas]

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!