If is a string over then let denote the number of ’s in and the number of ’s in . Which one of the following languages is not regular?
View worked solution
Answer: C
To determine which language is not regular, we analyze each option based on whether it requires finite or infinite memory (states) to be recognized.
-
The set of 3-digit prime numbers is finite (ranging from to ). Since the number of 's is restricted to a finite set of values and there is no restriction on 's, a DFA only needs to count 's up to . Any count beyond can go to a dead state. Since this requires a finite number of states, the language is regular.
-
This condition requires that at any point during the scanning of the string, the running difference between the number of 's and 's must stay within the range . If the difference ever exceeds this range, the string is rejected. This can be tracked using a finite number of states (representing differences of , plus a dead state). Thus, the language is regular.
-
This condition only constrains the final difference of the entire string. During the processing of the string, the intermediate difference can grow arbitrarily large (for example, in the string , the difference reaches before returning to ). To verify if the final difference is , a machine must keep track of an arbitrarily large difference, which requires infinite memory. Thus, this language is not regular.
-
This language requires the number of 's to be a multiple of and the number of 's to be a multiple of . This can be easily recognized by a DFA using the product construction with states. Since it requires finite memory, the language is regular.
Free practice · Your answers on this page are not saved.
