IN C++ PLEASE
dictionary. header
void AddWord(string word) This method adds a word to the tree. This is accomplished by reading the word character by character and creating a path in the tree exist. Below is the pseudocode for this method: currNode= root; for (each character c of the word) { if (the branch for character c is NULL) { set the branch of character c = new Node. set flag of this new Node to false } currNode = the pointer index of character c } Set the flag at the currNode to true Here is some code that will help you loop through each character of a string. // How to loop through each letter of a word string str = "hello"; for (int i = 0; i < str.size(); i++) { cout << str << endl; } the word if it doesn't While processing the characters, if you encounter a character that is not between 'a' and 'z', you should throw a DictionaryError with the message "Invalid character".
IN C++ PLEASE dictionary. header
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am