Consider the following languages :

L1 = {am bn | m ≠ n}

L2 = {am bn | m = 2n + 1}

L3 = {am bn | m ≠ 2n}

Which one of the following statement is correct ? 

This question was previously asked in
UGC NET Computer Science (Paper 3) Nov 2017 Official Paper
View all UGC NET Papers >
  1. Only L1 and L2 are context free languages
  2. Only L1 and L3 are context free languages
  3. Only L2 and L3 are context free languages
  4. L1, L2 and L3 are context free languages

Answer (Detailed Solution Below)

Option 4 : L1, L2 and L3 are context free languages
Free
UGC NET Paper 1: Held on 21st August 2024 Shift 1
10.8 K Users
50 Questions 100 Marks 60 Mins

Detailed Solution

Download Solution PDF

The correct answer is option 4.

key-point-imageKey Points

L1 = {am bn | m ≠ n}

  • It means m could be greater than (m>n) or less than 'n' (m<n)but m will not be equal to 'n'(m=n).
  • Since for accepting L1, we need storage so then a number of 'a' can be stored in it and when b's come as input a's and b's can be compared.
  • Since finite automata do not have a storage element hence language is not regular. 

 

F7 Raju S 29-4-2021 Swati D2

L2 = {am bn | m = 2n + 1}

L2 rewrite as {a2n+1bn }.

Here skip the first 'a'. If the input string reaches an empty symbol then it accepts the language(string: a) or if the input symbol is 'a' stores all a's in the stack. After every 'b' pop the two a's until it reaches the empty symbol then it accepts the language.

Hence the language L is CFL.

L3 = {am bn | m ≠ 2n}

It means m could be greater than (m>2n) or less than 'n' (m<2n) but m will not be equal to 'n'(m=n). Store all a's in the stack and for two b's pop one 'a'. If if there any a's in the stack (m>2n) or the top of the stack is Z0 and the input symbol is not reached to the empty symbol (m<2n) then it is accepting the language. 

Hence the language L3  is CFL.

Hence the correct answer is L1, L2 and L3 are context-free languages.

Latest UGC NET Updates

Last updated on Jun 6, 2025

-> The UGC NET Exam Schedule 2025 for June has been released on its official website.

-> The UGC NET Application Correction Window 2025 is available from 14th May to 15th May 2025.

-> The UGC NET 2025 online application form submission closed on 12th May 2025.

-> The June 2025 Exam will be conducted from 21st June to 30th June 2025

-> The UGC-NET exam takes place for 85 subjects, to determine the eligibility for 'Junior Research Fellowship’ and ‘Assistant Professor’ posts, as well as for PhD. admissions.

-> The exam is conducted bi-annually - in June and December cycles.

-> The exam comprises two papers - Paper I and Paper II. Paper I consists of 50 questions and Paper II consists of 100 questions. 

-> The candidates who are preparing for the exam can check the UGC NET Previous Year Papers and UGC NET Test Series to boost their preparations.

More Context Free Languages Questions

More Context Free Languages and Pushdown Automata Questions

Get Free Access Now
Hot Links: teen patti master app teen patti rummy teen patti teen patti 3a