emory-courses / dsa-java

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

[HW2] Non-exiting Prefix and methods for Putting words into Trie #160

Closed ywu496 closed 3 years ago

ywu496 commented 3 years ago

Fisrt question: For the getCandidate() as well as pickCandidate() method, if a prefix that doesn't exist in the Trie gets used as a parameter, should I make the prefix into a word(endState = true), or just add the prefix to the Trie structure without acknowledging it as a legitimate word(endState = false). Moreover, when getCandidate() gets called using a non-exisiting prefix, should I return nothing, or return just the prefix(assume it is the first time the non-exisitng prefix is being called)?

Second question: When the HW is being graded, how are the words put into the Trie in the process? Is it by using the "put" method in the parent class? If it is, is the TrieNode variable "value" initialized to null when putting words into the Trie?

jdchoi77 commented 3 years ago

1a. prefix should be introduced to the trie but not as a word when it is passed to the pickCandidate() method. 1b. the first time when getCandidate() is called on non-existing prefix, it should return an empty list.

  1. all values will be null initially.