# GATE | GATE CS 1996 | Question 10

Let LÂ âŠ†Â âˆ‘* whereÂ âˆ‘ = {a, b}. Which of the following is true ?
(A) L = { x | x has an equal number of a‘s and b‘s } is regular
(B) L = { anbn | nÂ â‰¥ 1 } is regular
(C) L = { x | x has more a‘s than b‘s } is regular
(D) L = {ambn | m ? 1, nÂ ? 1 } is regular

Explanation: For option (A) :-
L = { x | x has an equal number of a‘s and b‘s } is regular for equal number of aâ€™s and bâ€™s we need s stack for to store the number of aâ€™s and we push all aâ€™s into the stack and pop all bâ€™s for each aâ€™s hence, a cannot be regular language.

For option (B) :-
L = { anbn | nÂ â‰¥ 1 } is regular is also not regular , it is same as above language. This language also says that equal number of aâ€™s followed by equal number of bâ€™s so it also need a stack to push all aâ€™s and pop all bâ€™s for each aâ€™s.

For option (C) :-
L= { x | x has more a‘s than b‘s } is also not regular it is also CFL we need stack here for a should be greater than b.

For option (D) :-
L = {ambn | m â‰¥ 1, nÂ â‰¥ 1 } is regular language because there is no restriction that equal number of aâ€™s and bâ€™s this language only says that a should be followed by b therefore we can draw a DFA for it.

Option (D) is correct.

Quiz of this Question