A data structure can guide a search
Picture
A trie and backtracking solve different parts of a problem. The trie tells you which next letters are possible. Search explores the alternatives allowed by the current query. A wildcard turns one straight lookup path into a branching search through the same stored structure.
Predict
The pattern is ca. where . means exactly one arbitrary character. Can a lookup choose one child at the final position and stop if that child fails?
Reveal the reasoning
No. It may need to try other children. It can stop as soon as one succeeds because this query asks for existence, but one failed choice does not prove the other choices fail.
Go deeper: pair the structure position with query progress
def matches(node, pattern, i=0):
if i == len(pattern):
return None in node
char = pattern[i]
if char == ".":
return any(matches(child, pattern, i + 1)
for key, child in node.items() if key is not None)
return char in node and matches(node[char], pattern, i + 1)
trie = {"c": {"a": {"r": {None: True}, "t": {None: True}}}}
assert matches(trie, "ca.")
assert not matches(trie, "c.")
assert not matches(trie, "dog")
The state is the current trie node and position in the pattern. No mutation is needed, so recursive return already isolates alternatives. An ordinary character follows at most one edge. A wildcard follows all character edges until a successful completion is found.
For a trie with N nodes and pattern length L, this simple fixed-length wildcard search visits at most O(N) nodes, restricted to depth L, and uses O(L) recursion space. It can inspect far more nodes than a literal lookup.
Transfer to a letter board: explore adjacent cells while following trie edges. A missing prefix edge prunes the entire branch. Now a cell cannot usually repeat within the current word, so board search also needs path-local visited information that is restored when exploring another route. A global visited-cell set would lose words.
Analogy limit: ., matching exactly one character, differs from *, which may match several. Changing wildcard semantics changes transitions, state dependencies, and possibly repeated states.
Change one rule
The query must return every matching word. Is stopping after the first success still correct?
Check the variation
No. Explore all matching branches and construct their outputs. The data structure can prune impossible prefixes, but it cannot skip required matches.
Connect
Visited semantics explain board-path memory. DP state asks whether any repeated search situations actually have the same reusable remaining answer.