SlideShare une entreprise Scribd logo
1  sur  10
UNIT - II
REGULAR EXPRESSIONS AND LANGUAGES
 Regular expression
 Regular Languages
 Equivalence of Finite Automata and regular expressions
 Proving languages to be not regular (Pumping Lemma)
 Closure properties of regular languages.
LIST OF IMPORTANT QUESTIONS
UNIT - II
REGULAR EXPRESSIONS AND LANGUAGES
PART – A
1. Show whether the language L = {0n12n | n > 0} is regular or not using pumping
lemma (April/May 2017)
2. What are the closure properties of regular languages? (Nov/Dec 2016)
(May/June2014), (May/June2013)
3. State the pumping lemma for Regular Languages. (May/June 2016)(Nov/Dec
2014)(Nov/Dec 2013)
4. Write Regular Expression for the set of strings over {0,1} that have atleast
one.(Nov/Dec 2015)
5. What is a regular expression? (May/June2013)
PART B
1) Find the regular expression of a language that consists of set of string starts with
11 as well as ends with 00 using Rij formula. (April/May2015)
2) Discuss the closure properties of regular languages. (Nov/Dec2013)
(May/June2013) (Or)Prove that the class of regular sets is closed under
complementation. (May/June2014)
3) Prove that “A Language L is accepted by some DFA if and only if L is accepted by
some NFA”. (or) Let L be set accepted by a NFA and then prove that there exists a
DFA that accepts L. (Nov/Dec2015) (Nov/Dec2014) (Nov/Dec2013)
4) Discuss on regular Expression. Write a regular expression for set of strings that
consist of alternating 0’s and 1’s. (May/June 2016) (May/June2013)
ii) Prove that the following languages are not regular. (May/June2013)
1) {02n | n > 1}
2) {ambnam+n | m > 1 and n > 1} (or) L = { 0m1n0m+n | m > 1 and n > 1}
(Nov/Dec2013)
UNIT - II
REGULAR EXPRESSIONS AND LANGUAGES
PART A
1) Show whether the language L = {0n12n | n > 0} is regular or not using pumping
lemma(April/May 2017)
SOLUTION:
The number of states is 3n > n. w = 0n12n
The length of the string |w| = 3n > n
Assume xy = 0m, y = 0j , z = 0n-m . 12n
xykz = xy(y)k-1z
= 0m . 0j(k-1) . 0n-m . 12n
xykz = 0n + j(k-1) . 12n
Apply k = 0 xykz = 0n - j. 12n L
Apply k = 1 xykz = 0n . 12n L
Apply k = 2 xykz = 0n + j. 12n L
Thus the Language L = {0n12n | n > 0} is not a regular Language
2) What are the closure properties of regular languages? (Nov/Dec 2016)
(May/June2014), (May/June2013)
CLOSURE PROPERTIES OF REGULAR LANGUAGES
The regular languages are closed under
i. The union of two regular languages is regular.
ii. The intersection of two regular languages is regular.
iii. The complement of two regular languages is regular.
iv. The difference of two regular languages is regular.
v. The reversal of regular languages is regular.
vi. The closure of regular languages is regular.
vii. The concatenation of regular languages is regular.
viii.The homomorphism of regular languages is regular.
ix. The inverse Homomorphism of regular languages is regular.
3) State the pumping lemma for Regular Languages (May/June 2016)(Nov/Dec
2014)(Nov/Dec 2013)
PUMPING LEMMA:
Let L be a regular languages. Then there exists a constant n such that for every string w
in L such that |w| ≥ n. w=xyz such that
i. y ≠ ε
ii. |xy| ≤ n
iii. for all i ≥ 0, xy iz Σ L.
4) Write Regular Expression for the set of strings over {0, 1} that have atleast one.
(Nov/Dec 2015)
REGULAR EXPRESSION OF STRINGS {0, 1}:
1(0 + 1)*
.
5) Define the term epsilon transition.[May/Jun 13]
a. The ε is a character used to indicate null string.
b. i.e. the string which is used simply for transition from one state to other state
without any input.
6) Define the language accepted by a NFA
a. We define the language of a NFA A = (Q,Σ, δ,q0,F) by
b. L(A) = { w|δ(q0,w) ∩F ≠ Φ }.
7) Define the language accepted by a DFA
a. We define the language of a DFA A = (Q,Σ, δ,q0,F)by
b. L(A) = { w|δ(q0,w) is in F}.
8) Differentiate L* and L+
a. L* denotes Kleene closure and is given by L* = U Li i=0
b. example: 0* ={ Є,0,00,000,… }
c. Language includes empty words also.
d. L+ denotes Positive closure and is given by L+= U Li i=1
9) Define Substring.
A string v appears within another string w(w=uv) is called “substring of w.” IF w=uv, then
substrings u & v are said to be prefix and suffix of w respectively
10) What is a regular expression? (May/June2013)
The Language accepted by finite automata are easily described by simple expression
called regular expression. A regular expression is a string that describes the whole set of
strings according to certain syntax rules. These expressions are used by many text
editors and utilities to search bodies of text for certain patterns etc.
Let Σ be an alphabet. The regular expression over Σ and the sets they denote are:
i. ε is a R.E, denotes empty set and Language L(ε) = { ε}.
ii. pie is a R.E denotes the set { } and Language L(pie) = { pie}.
iii. A variable represented in upper case like L is any language.
iv.For each ‘a’ in Σ , ‘a’ is a R.E and denotes the set {a}.
v. If r and s are regular expression, then
i. If ‘r’ and ‘s’ are R.E denoting the languages R and S respectively then
(r+s),
ii. (rs) and (r*) are R.E that denote the sets RUS, RS and R* respectively.
11)Write a r.e to denote a language L which accepts all the strings which begin or end
with either 00 or 11.
The r.e consists of two parts:
L1=(00+11) (any no of 0’s and 1’s) =(00+11)(0+1)*
L2=(any no of 0’s and 1’s)(00+11) =(0+1)*(00+11)
Hence r.e R=L1+L2 =[(00+11)(0+1)*] + [(0+1)* (00+11)]
12)Construct a r.e for the language over the set ∑={a,b} in which total number of a’s
are divisible by 3
( b* a b* a b* a b*)*
13)What is: (i) (0+1)* (ii)(01)* (iii)(0+1) (iv)(0+1)+ [Remember]
(0+1)*= { Є, 0 , 1 , 01 , 10 ,001 ,101 ,101001,… }
Any combinations of 0’s and 1’s.
(01)*={ Є, 01 ,0101 ,010101 ,… }
All combinations with the pattern 01. (0+1)= 0 or 1,No other possibilities.
(0+1)+= {0,1,01,10,1000,0101,………………………………….}
14)Reg exp denoting a language over ∑={1} having (i) even length of string (ii) odd
length of a string.
i. Even length of string R=(11)*
ii. Odd length of the string R=1(11)*
15)Reg exp for: (i) All strings over {0,1} with the substring ‘0101’ (ii) All strings
beginning with ’11 ‘ and ending with ‘ab’ (iii) Set of all strings over {a,b}with 3
consecutive b’s. (iv) Set of all strings that end with ‘1’and has no substring
‘00’
i. (0+1)* 0101(0+1)*
ii. 11(1+a+b)* ab
iii. (a+b)* bbb (a+b)*
iv. (1+01)* (10+11)* 1
16)Construct a r.e for the language which accepts all strings with atleast two c’s
over the set Σ={c,b}
(b+c)* c (b+c)* c (b+c)*
17)What are the applications of Regular expressions and Finite automata [Remember]
a. Lexical analyzers and Text editors are two applications. Lexical analyzers:
b. The tokensof the programminglanguage can be expressed
using regular expressions.
c. The lexical analyzer scans the input program and separates the tokens.For eg
identifier can be expressed as a regular expression
d. as: (letter)(letter+digit)*
e. If anything in the source language matches with this reg exp then it is recognized
as an identifier.The letter is{A,B,C,………..Z,a,b,c….z} and digit is {0,1,…9}.Thus
reg exp identifies token in a language.
f. Text editors:
g. These are programs used for processing the text. For example UNIX text editors
uses the reg exp for substituting the strings such as: S/bbb*/b/
h. Gives the substitute a single blank for the first string of two or more blanks in a
given line. In UNIX text editors any reg exp is converted to an NFA with
Єtransitions, this NFA can be then simulated directly.
18)Reg exp for the language that accepts all strings in which ‘a’ appears tripled over
the set Σ ={a} [Apply]
19)reg exp=(aaa)*
20)Reg exp for the language such that every string will have atleast one ‘a’ followed by
atleast one ‘b’. [Apply]
21)R=a+b+
22)Write the exp for the language starting with and has no consecutive b’s. [Apply]
23)reg exp=(a+ab)*
24)Construct a regular expression denoting odd numbers in their binary
representation. [Apply]
25){0/1}*1
26)Construct a regular expression denoting even numbers in their binary
representation. [Apply]
27){0/1}*0
28)Construct a regular expression denoting the set of all strings of 0 and 1 beginning
with 0 and ending with 1 . [Apply] [Nov 2012]
29)0{0/1}*1
30)Construct a regular expression denoting the set of all strings over {a,b} such that
all starts with a and ends with ab. [Apply]
31)a{a/b}*ab
32)Construct a regular expression denoting the set of all strings of 0 and 1 ending in
00 . [Apply] [Nov 2012]
33){0/1}*00
34)Write the regular expression for set of all strings over {0,1} that have at least one.
[Apply] (Nov / Dec 2015)
35)R=(0+1)*1(0+1)*
36)Construct a regular expression denoting the set of all strings over {a,b} such that
all contains three a’s. [Apply]
37)b*ab*ab*ab*
38)What does the following regular expression denote 0*1*2*[Analyze]
39)The set of all words over {0,1} such that all starts with 0 number of 0’s or 1 0’s or
more number of 0’s followed by similar patterns of 1’s and 2’s.
40)Construct a regular expression for the set of strings that consist alternate 0’s and
1’s. [Apply]
41)(01)* + (10)*+ 0(10)* + 1(01)*
42)What are the applications of pumping lemma? [Remember] Pumping lemma is used
to check if a language is regular or not. (i).Assume that the language(L) is regular.
43)(ii).Select a constant ‘n’.
44)(iii).Select a string(z) in L, such that |z|>n.
10
45)Split the word z into u,v and w such that |uv|<=n and |v|>=1.
46)You achieve a contradiction to pumping lemma that there exists an ‘i’ Such that
uviw is not in L.Then L is not a regular language.
47)

Contenu connexe

Similaire à PART A.doc

Automata_Theory_and_compiler_design_UNIT-1.pptx.pdf
Automata_Theory_and_compiler_design_UNIT-1.pptx.pdfAutomata_Theory_and_compiler_design_UNIT-1.pptx.pdf
Automata_Theory_and_compiler_design_UNIT-1.pptx.pdfTONY562
 
Mod 2_RegularExpressions.pptx
Mod 2_RegularExpressions.pptxMod 2_RegularExpressions.pptx
Mod 2_RegularExpressions.pptxRaviAr5
 
Lecture 3,4
Lecture 3,4Lecture 3,4
Lecture 3,4shah zeb
 
Lecture 3,4
Lecture 3,4Lecture 3,4
Lecture 3,4shah zeb
 
Chapter2CDpdf__2021_11_26_09_19_08.pdf
Chapter2CDpdf__2021_11_26_09_19_08.pdfChapter2CDpdf__2021_11_26_09_19_08.pdf
Chapter2CDpdf__2021_11_26_09_19_08.pdfDrIsikoIsaac
 
hghghghhghghgggggggggggggggggggggggggggggggggg
hghghghhghghgggggggggggggggggggggggggggggggggghghghghhghghgggggggggggggggggggggggggggggggggg
hghghghhghghggggggggggggggggggggggggggggggggggadugnanegero
 
Theory of Automata Lesson 02
Theory of Automata Lesson 02Theory of Automata Lesson 02
Theory of Automata Lesson 02hamzamughal39
 
Automata
AutomataAutomata
AutomataGaditek
 
Automata
AutomataAutomata
AutomataGaditek
 
End semexam | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
End semexam | Theory of Computation | Akash Anand | MTH 401A | IIT KanpurEnd semexam | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
End semexam | Theory of Computation | Akash Anand | MTH 401A | IIT KanpurVivekananda Samiti
 
Theory of computing
Theory of computingTheory of computing
Theory of computingRanjan Kumar
 

Similaire à PART A.doc (20)

Automata_Theory_and_compiler_design_UNIT-1.pptx.pdf
Automata_Theory_and_compiler_design_UNIT-1.pptx.pdfAutomata_Theory_and_compiler_design_UNIT-1.pptx.pdf
Automata_Theory_and_compiler_design_UNIT-1.pptx.pdf
 
Mod 2_RegularExpressions.pptx
Mod 2_RegularExpressions.pptxMod 2_RegularExpressions.pptx
Mod 2_RegularExpressions.pptx
 
Lecture 3,4
Lecture 3,4Lecture 3,4
Lecture 3,4
 
Lecture 3,4
Lecture 3,4Lecture 3,4
Lecture 3,4
 
Chapter2CDpdf__2021_11_26_09_19_08.pdf
Chapter2CDpdf__2021_11_26_09_19_08.pdfChapter2CDpdf__2021_11_26_09_19_08.pdf
Chapter2CDpdf__2021_11_26_09_19_08.pdf
 
L_2_apl.pptx
L_2_apl.pptxL_2_apl.pptx
L_2_apl.pptx
 
UNIT_-_II.docx
UNIT_-_II.docxUNIT_-_II.docx
UNIT_-_II.docx
 
Lesson 02
Lesson 02Lesson 02
Lesson 02
 
Lesson 02
Lesson 02Lesson 02
Lesson 02
 
hghghghhghghgggggggggggggggggggggggggggggggggg
hghghghhghghgggggggggggggggggggggggggggggggggghghghghhghghgggggggggggggggggggggggggggggggggg
hghghghhghghgggggggggggggggggggggggggggggggggg
 
Theory of Automata Lesson 02
Theory of Automata Lesson 02Theory of Automata Lesson 02
Theory of Automata Lesson 02
 
Unit2 Toc.pptx
Unit2 Toc.pptxUnit2 Toc.pptx
Unit2 Toc.pptx
 
Automata
AutomataAutomata
Automata
 
Automata
AutomataAutomata
Automata
 
End semexam | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
End semexam | Theory of Computation | Akash Anand | MTH 401A | IIT KanpurEnd semexam | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
End semexam | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
 
TOC question bank.pdf
TOC question bank.pdfTOC question bank.pdf
TOC question bank.pdf
 
Theory of computing
Theory of computingTheory of computing
Theory of computing
 
To lec 03
To lec 03To lec 03
To lec 03
 
FLAT.pdf
FLAT.pdfFLAT.pdf
FLAT.pdf
 
Question bank toafl
Question bank toaflQuestion bank toafl
Question bank toafl
 

Dernier

Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...KokoStevan
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfSanaAli374401
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 

Dernier (20)

Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 

PART A.doc

  • 1. UNIT - II REGULAR EXPRESSIONS AND LANGUAGES  Regular expression  Regular Languages  Equivalence of Finite Automata and regular expressions  Proving languages to be not regular (Pumping Lemma)  Closure properties of regular languages.
  • 2. LIST OF IMPORTANT QUESTIONS UNIT - II REGULAR EXPRESSIONS AND LANGUAGES PART – A 1. Show whether the language L = {0n12n | n > 0} is regular or not using pumping lemma (April/May 2017) 2. What are the closure properties of regular languages? (Nov/Dec 2016) (May/June2014), (May/June2013) 3. State the pumping lemma for Regular Languages. (May/June 2016)(Nov/Dec 2014)(Nov/Dec 2013) 4. Write Regular Expression for the set of strings over {0,1} that have atleast one.(Nov/Dec 2015) 5. What is a regular expression? (May/June2013) PART B 1) Find the regular expression of a language that consists of set of string starts with 11 as well as ends with 00 using Rij formula. (April/May2015) 2) Discuss the closure properties of regular languages. (Nov/Dec2013) (May/June2013) (Or)Prove that the class of regular sets is closed under complementation. (May/June2014) 3) Prove that “A Language L is accepted by some DFA if and only if L is accepted by some NFA”. (or) Let L be set accepted by a NFA and then prove that there exists a DFA that accepts L. (Nov/Dec2015) (Nov/Dec2014) (Nov/Dec2013) 4) Discuss on regular Expression. Write a regular expression for set of strings that consist of alternating 0’s and 1’s. (May/June 2016) (May/June2013) ii) Prove that the following languages are not regular. (May/June2013) 1) {02n | n > 1} 2) {ambnam+n | m > 1 and n > 1} (or) L = { 0m1n0m+n | m > 1 and n > 1} (Nov/Dec2013)
  • 3. UNIT - II REGULAR EXPRESSIONS AND LANGUAGES PART A 1) Show whether the language L = {0n12n | n > 0} is regular or not using pumping lemma(April/May 2017) SOLUTION: The number of states is 3n > n. w = 0n12n The length of the string |w| = 3n > n Assume xy = 0m, y = 0j , z = 0n-m . 12n xykz = xy(y)k-1z = 0m . 0j(k-1) . 0n-m . 12n xykz = 0n + j(k-1) . 12n Apply k = 0 xykz = 0n - j. 12n L Apply k = 1 xykz = 0n . 12n L Apply k = 2 xykz = 0n + j. 12n L
  • 4. Thus the Language L = {0n12n | n > 0} is not a regular Language 2) What are the closure properties of regular languages? (Nov/Dec 2016) (May/June2014), (May/June2013) CLOSURE PROPERTIES OF REGULAR LANGUAGES The regular languages are closed under i. The union of two regular languages is regular. ii. The intersection of two regular languages is regular. iii. The complement of two regular languages is regular. iv. The difference of two regular languages is regular. v. The reversal of regular languages is regular. vi. The closure of regular languages is regular. vii. The concatenation of regular languages is regular. viii.The homomorphism of regular languages is regular. ix. The inverse Homomorphism of regular languages is regular. 3) State the pumping lemma for Regular Languages (May/June 2016)(Nov/Dec 2014)(Nov/Dec 2013) PUMPING LEMMA: Let L be a regular languages. Then there exists a constant n such that for every string w in L such that |w| ≥ n. w=xyz such that i. y ≠ ε ii. |xy| ≤ n iii. for all i ≥ 0, xy iz Σ L. 4) Write Regular Expression for the set of strings over {0, 1} that have atleast one. (Nov/Dec 2015) REGULAR EXPRESSION OF STRINGS {0, 1}: 1(0 + 1)* . 5) Define the term epsilon transition.[May/Jun 13] a. The ε is a character used to indicate null string.
  • 5. b. i.e. the string which is used simply for transition from one state to other state without any input. 6) Define the language accepted by a NFA a. We define the language of a NFA A = (Q,Σ, δ,q0,F) by b. L(A) = { w|δ(q0,w) ∩F ≠ Φ }. 7) Define the language accepted by a DFA a. We define the language of a DFA A = (Q,Σ, δ,q0,F)by b. L(A) = { w|δ(q0,w) is in F}. 8) Differentiate L* and L+ a. L* denotes Kleene closure and is given by L* = U Li i=0 b. example: 0* ={ Є,0,00,000,… } c. Language includes empty words also. d. L+ denotes Positive closure and is given by L+= U Li i=1 9) Define Substring. A string v appears within another string w(w=uv) is called “substring of w.” IF w=uv, then substrings u & v are said to be prefix and suffix of w respectively 10) What is a regular expression? (May/June2013) The Language accepted by finite automata are easily described by simple expression called regular expression. A regular expression is a string that describes the whole set of strings according to certain syntax rules. These expressions are used by many text editors and utilities to search bodies of text for certain patterns etc. Let Σ be an alphabet. The regular expression over Σ and the sets they denote are: i. ε is a R.E, denotes empty set and Language L(ε) = { ε}. ii. pie is a R.E denotes the set { } and Language L(pie) = { pie}. iii. A variable represented in upper case like L is any language. iv.For each ‘a’ in Σ , ‘a’ is a R.E and denotes the set {a}. v. If r and s are regular expression, then i. If ‘r’ and ‘s’ are R.E denoting the languages R and S respectively then (r+s), ii. (rs) and (r*) are R.E that denote the sets RUS, RS and R* respectively. 11)Write a r.e to denote a language L which accepts all the strings which begin or end with either 00 or 11.
  • 6. The r.e consists of two parts: L1=(00+11) (any no of 0’s and 1’s) =(00+11)(0+1)* L2=(any no of 0’s and 1’s)(00+11) =(0+1)*(00+11) Hence r.e R=L1+L2 =[(00+11)(0+1)*] + [(0+1)* (00+11)] 12)Construct a r.e for the language over the set ∑={a,b} in which total number of a’s are divisible by 3 ( b* a b* a b* a b*)* 13)What is: (i) (0+1)* (ii)(01)* (iii)(0+1) (iv)(0+1)+ [Remember] (0+1)*= { Є, 0 , 1 , 01 , 10 ,001 ,101 ,101001,… } Any combinations of 0’s and 1’s. (01)*={ Є, 01 ,0101 ,010101 ,… } All combinations with the pattern 01. (0+1)= 0 or 1,No other possibilities. (0+1)+= {0,1,01,10,1000,0101,………………………………….} 14)Reg exp denoting a language over ∑={1} having (i) even length of string (ii) odd length of a string. i. Even length of string R=(11)* ii. Odd length of the string R=1(11)* 15)Reg exp for: (i) All strings over {0,1} with the substring ‘0101’ (ii) All strings beginning with ’11 ‘ and ending with ‘ab’ (iii) Set of all strings over {a,b}with 3 consecutive b’s. (iv) Set of all strings that end with ‘1’and has no substring ‘00’ i. (0+1)* 0101(0+1)* ii. 11(1+a+b)* ab iii. (a+b)* bbb (a+b)* iv. (1+01)* (10+11)* 1 16)Construct a r.e for the language which accepts all strings with atleast two c’s over the set Σ={c,b} (b+c)* c (b+c)* c (b+c)* 17)What are the applications of Regular expressions and Finite automata [Remember] a. Lexical analyzers and Text editors are two applications. Lexical analyzers: b. The tokensof the programminglanguage can be expressed using regular expressions.
  • 7. c. The lexical analyzer scans the input program and separates the tokens.For eg identifier can be expressed as a regular expression d. as: (letter)(letter+digit)* e. If anything in the source language matches with this reg exp then it is recognized as an identifier.The letter is{A,B,C,………..Z,a,b,c….z} and digit is {0,1,…9}.Thus reg exp identifies token in a language. f. Text editors: g. These are programs used for processing the text. For example UNIX text editors uses the reg exp for substituting the strings such as: S/bbb*/b/ h. Gives the substitute a single blank for the first string of two or more blanks in a given line. In UNIX text editors any reg exp is converted to an NFA with Єtransitions, this NFA can be then simulated directly.
  • 8. 18)Reg exp for the language that accepts all strings in which ‘a’ appears tripled over the set Σ ={a} [Apply] 19)reg exp=(aaa)* 20)Reg exp for the language such that every string will have atleast one ‘a’ followed by atleast one ‘b’. [Apply] 21)R=a+b+ 22)Write the exp for the language starting with and has no consecutive b’s. [Apply] 23)reg exp=(a+ab)* 24)Construct a regular expression denoting odd numbers in their binary representation. [Apply] 25){0/1}*1 26)Construct a regular expression denoting even numbers in their binary representation. [Apply] 27){0/1}*0 28)Construct a regular expression denoting the set of all strings of 0 and 1 beginning with 0 and ending with 1 . [Apply] [Nov 2012] 29)0{0/1}*1 30)Construct a regular expression denoting the set of all strings over {a,b} such that all starts with a and ends with ab. [Apply] 31)a{a/b}*ab 32)Construct a regular expression denoting the set of all strings of 0 and 1 ending in 00 . [Apply] [Nov 2012] 33){0/1}*00 34)Write the regular expression for set of all strings over {0,1} that have at least one. [Apply] (Nov / Dec 2015) 35)R=(0+1)*1(0+1)* 36)Construct a regular expression denoting the set of all strings over {a,b} such that all contains three a’s. [Apply] 37)b*ab*ab*ab* 38)What does the following regular expression denote 0*1*2*[Analyze] 39)The set of all words over {0,1} such that all starts with 0 number of 0’s or 1 0’s or more number of 0’s followed by similar patterns of 1’s and 2’s. 40)Construct a regular expression for the set of strings that consist alternate 0’s and 1’s. [Apply] 41)(01)* + (10)*+ 0(10)* + 1(01)*
  • 9. 42)What are the applications of pumping lemma? [Remember] Pumping lemma is used to check if a language is regular or not. (i).Assume that the language(L) is regular. 43)(ii).Select a constant ‘n’. 44)(iii).Select a string(z) in L, such that |z|>n.
  • 10. 10 45)Split the word z into u,v and w such that |uv|<=n and |v|>=1. 46)You achieve a contradiction to pumping lemma that there exists an ‘i’ Such that uviw is not in L.Then L is not a regular language. 47)