k: the length of the string you are looking for or inserting.
For Search Worst: O(26*k) = O(k) Average: O(k)
The complexity of Trie does not change with the number of lines you are looking for, only with the length of the search string. This is why Trie is used when the number of lines to search is large, for example, searching for all dictionaries in an English dictionary.
For Insertion Worst: O(26*k) = O(k) Average: O(k) Best: O(1)
So yes, you are right. You probably saw O (MN), and that may have confused you, but it just says when you need to perform O (k) operations N times.
Aaron source share