Question: def wildcard _ search ( self , pattern: str ) - > list: Searches for words in the Trie that match a

def wildcard_search(self, pattern: str)-> list:
"""
Searches for words in the Trie that match a given pattern including wildcards.
The '*' wildcard matches any sequence of characters (including an empty sequence),
and '?' matches any single character.
:param pattern: The pattern to search for, which may include '*' and '?' wildcards.
:return: List of strings; all words in the Trie that match the given wildcard pattern.
:complexity: O(P + K), where P is the length of the pattern and K is the number of matching words.
Example:
If the Trie contains 'apple', 'app', 'apricot', 'banana':
wildcard_search('a*p') should return ['app', 'apple', 'apricot']
wildcard_search('a??le') should return ['apple']
"""
please use in python

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!