If s is a string over (0+1)∗, then let n0(s) denote the number of 0's in s and n1(s) the number of 1's in s. Which one of the following languages is not regular?
Open in App
Solution
Choise (a) is regular since it is finite.
Choise (b) is regular since although comparision is made between 0's and 1's, it is for all prefixes and this can be done by DFA.
Choice (c) involves comparision of number of 0's and 1's but for the string as a whole, and this cannot be done by a dfa, since it has finite memory and has no stack for counting upto infinity. Therefore, choice (c) is not regular.
Choice (d) is regular since n0(s)mod7=n1(s)mod5=0 means number of 0's is divisible by 7 and number of 1's is divisible by 5 and this can be accepted by a dfa with 7 × 5 = 35 states.
A minimal DFA that will accept the language of choice (b) is shown below: