I have hit the wall with the LOAD FUNCTION of PSet6. Does the following pseudocode look correct? Thanks for guidance.
- open dictionary file.
- create a node struct
- create an array of list_pointers (our hash table)
- create a hash function
- read dictionary file one character at a time putting each character into a buffer until a \0.
- put buffer in as argument to the hash function.
- take integer value recevied from hash function and go to list_pointer[integer].
- if there is no word yet add to end of list pointer.
- if there is a word, then there is a linked list of one or more words. then traverse the list comparing each character of buffer to word in struct of linked list until you find the right place to insert. compare buffer[i] to node.word[i] if buffer[i] < node.word[i] go to buffer[i +1] and compare again if buffer[i] > node.word[i] insert word if buffer[i] == buffer[\0] then end of word is reached and word is already in dictionary return false
- when EOF is reached for dictionary, free memory for creating a node. end function.