Question: The first step in parsing a language often involves matching an input string against a set of a patterns. In this problem, we allow a

The first step in parsing a language often involves matching an input string against a set of a patterns.
In this problem, we allow a pattern to be any sequence of alphabetic letters (e.g.,'a','b',...,'z') and the special character '?'(which can be any single alphabetic character). For example, the pattern ab?d?f would match the inputs abcdef,abbddf, and abzdzf, but it would not match bbbbbb or abc.
We call a set of patterns unambiguous if no input string can be matched by two or more patterns in the set. For example, the set of patterns {a, bc,?a} is unambiguous, but the set of patterns {a, bc,?c} is ambiguous because the patterns bc and ?c both match the input string bc.
Given a set of patterns, briefly describe an efficient algorithm that determines whether the set is ambiguous. You may use one of the following data structures to help you: BST, AVL Tree, Trie, LLRB Tree.
Your description should take 1-2 sentences. Be sure to also justify the efficiency of your answer by providing the worst case running time of your algorithm in O() notation. Use the variable n to represent the number of patterns in your set.

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!