emory-courses / dsa-java

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

[HW2] Question Regarding Generic Type "value" #129

Closed HallOfSam closed 3 years ago

HallOfSam commented 3 years ago

Hello! I have a quick question regarding the generic type field value in Trie. I understand that value can be of type Integer, as implemented in Quiz 5 where value indicates whether a word is added into the Trie firstly, secondly, and so on. However, in HW2 , the type of field "value" is List, and I have no idea what it indicates and how it can be used. Does anyone know what "value" means in this scenario?

Also, I have a question similar to Carol's question posted in issues: why does the test only expect 3 candidates when in reality 20 words is required (as indicated by "max= 20")?

Thanks in advance!

caroltang0331 commented 3 years ago

I think might be because if you want to return a list of candidate(String) of a certain trie node (say the "h" in "sh"), you can just return the value of that node, which will give u all the candidate in the form of a list? So like u basically can just update/manipulate that value of node everything you pick or get candidate. but idk im really confused about this hw im just guessing

HallOfSam commented 3 years ago

I think might be because if you want to return a list of candidate(String) of a certain trie node (say the "h" in "sh"), you can just return the value of that node, which will give u all the candidate in the form of a list? So like u basically can just update/manipulate that value of node everything you pick or get candidate. but idk im really confused about this hw im just guessing

I think I've figured it out. When every word in the provided dictionary is added to the Trie, the value is set to be "null". So basically it does nothing.