What is the best-case runtime for checking whether a trie contains a particular
ID: 3606794 • Letter: W
Question
What is the best-case runtime for checking whether a trie contains a particular string? Select all that apply.
What is the best-case runtime for checking whether a trie contains a particular string? Select all that apply. O(n), where n is the number of nodes in the trie 0 0(n), where n is the number of strings that have been inserted into the trie O(n), where n is the length of the string we're searching for O(1), because it's possible for the trie to have just one node (the root node) O(1), because the string we're searching for could have a single character O(1), because the trie could be empty O(1), because the string we're searching for could be the empty string (i.e., it has zero characters) O(1), because the first letter in the string we're searching for might not be represented in the trie O(1), because the string we're searching for might be the prefix of a much longer string (i.e., searching for "be" when the trie contains "benevolent')Explanation / Answer
IN trie we search based on maching charcter from begining and hence search will always depend on length of string
So
O(n) where n is the length of the string we're searching for
O(1) because it's possible for the trie to have just one node (the root node)
O(1) because the string we're searching for could have single charcter
O(1) because the trie could be empty
O(1) because the string we're searching for could be the empty string
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.