emory-courses / dsa-java

Data Structures and Algorithms in Java
https://emory.gitbook.io/dsa-java/
42 stars 55 forks source link

[HW#2] Adding non-existing candidates? #164

Closed Shreya3554 closed 4 years ago

Shreya3554 commented 4 years ago

Replace # in the title with the appropriate homework number. For pickCandidate(prefix, candidate), if the candidate does not exist, do we need to add the candidate to the trie?

TFloyd1989 commented 4 years ago

Adding to this question, should the word be labeled as a dictionary term via its endstate as well?

skhardi commented 4 years ago

To my understanding, yes if the candidate is not already in the trie, it should be added with its endstate set to true. If the prefix is not in the trie, then it should be added to trie but the endstate will be false.

marvinquiet commented 4 years ago

Thank you @skhardi for answering!