00:00:00,762 --> 00:00:02,720 SPEAKER: Now that we've created our dictionary, it's time to implement check, which will check whether a given string is in our dictionary or not. Check is going to be a case insensitive function. That means that whether or not the word that you're checking contains uppercase letters or lowercase letters or a mixture there of, it's going to return true as long as any combination of those cases is found in the dictionary. Then finally, we're going to let you assume that the strings that you're passed in, will only have alphabetical characters or apostrophes. So no need to worry about cases with any numbers or other characters. The premise of check is that if the word exists, then you'll be able to find it in your dictionary data structure. I'm going to follow the same order as I did in load, so we're going to talk about linked lists and hashtables first. And then, we'll talk about tries. In a hashtable dictionary, which bucket would the word be in? Remember that. A hashtable is simply an array of linked lists where each element of the array is a node pointer. So then, once we know which linked list to search, we're going to use the string case comparison function to compare those two strings. So how do we search that bucket for our word or in other words, traverse a linked list? Well let's assume first, that I've declared a node pointer, called head, that points to the very first node in a linked list. Then I declare another node pointer, called cursor in this case, that points to the very same node that the head pointer points to. Notice here, that when I created the cursor pointer, I didn't malloc any space. That's because I'm not making a new node, I'm simply creating a pointer that will point to preexisting nodes in my linked list. So then, we have a loop that will execute as long as the cursor is not null. Within that loop, you have space to do some process, some repeated process on every single node, whether it is change the value or calculate something or in this case, compare strings. After you've done that, then you can reassign cursor to whatever that node is pointing to. And then, continue your loop until cursor points to null. Now how do we traverse a try? Well for each letter in the input word, then we'll go to the corresponding element in children in that try. If it's null, then that means the word is misspelled. But if it's not, then we can move to the next letter until we reach the end of the input word. Now even if we've successfully followed every single letter down our try, then that doesn't necessarily mean that our input word is a word in our dictionary. The final step that we'll need to do is to check whether the Boolean is word is true or not. If true, we can return true. If false, then that's an invalid word. Now that you know how to traverse your data structure, you can get to checking.