This question is almost the opposite of Efficient data structure for word lookup with wildcards
Suppose we have a database of urls
http://aaa.com/
http://bbb.com/
http://ccc.com/
....
To find if a url
is on the list I can make a binary-search
and get the results in O(log n)
time, n the size of the list.
This structure served well for many years but now I'd like to have wildcards in the database entries, like:
http://*aaa.com/*
http://*bbb.com/*
http://*ccc.com/
....
And the naive search would result in a full scan with O(n)
time for finding.
Which data structure could have find in less than O(n)
?