SlideShare a Scribd company logo
1 of 9
REMOVING AMBIGUITY
FROM CFG
1
Group Members:
1. Muradul Islam Jamil (152-35-1203)
2. Mahadi Hasan Joy (152-35-1207)
3. Mazed Mourshed (152-35-1215)
Md. Anwar Hossen
Lecturer, Dept. of Software Engineering
Daffodil International University
2
AMBIGUITY IN CFG
If a context free grammar has more than one derivation tree
for some string, it is called an ambiguous grammar. There
exist multiple right-most or left-most derivations for some
string generated from
that grammar.
3
PROBLEM
Check whether the grammar G with production rules −
S → AB | aaB
A → a | Aa
B → b
4
SOLUTION
Let’s find out the derivation tree for the string “aab". It has two leftmost deriv
i) S → aaB → aab
ii) S → AB →AaB → aaB → aab
5
ANOTHER PROBLEM
Check whether the grammar G with
production rules −
S → S + S | S * S | a
6
SOLUTION
Let’s find out the derivation tree for the string “a+a+a". It has two leftmost d
i) S → S + S → S + S + S → a + a + S → a + a + a
ii) S → S + S → S + S + S → S + a + a → a + a + a
7
SOLUTION
Let’s find out the derivation tree for the string “a+a*a". It has two leftmost de
i) S → S + S → a + S → a + S * S → a + a * a
ii) S → S * S → S + S * S → a + a * S → a + a * a
8
THANK
YOU
9

More Related Content

What's hot

Techniques & applications of Compiler
Techniques & applications of CompilerTechniques & applications of Compiler
Techniques & applications of CompilerPreethi AKNR
 
Homophonic Substitution Cipher
Homophonic Substitution CipherHomophonic Substitution Cipher
Homophonic Substitution CipherSHUBHA CHATURVEDI
 
Context Free Grammar
Context Free GrammarContext Free Grammar
Context Free GrammarAkhil Kaushik
 
Automata theory -- NFA and DFA construction
Automata theory -- NFA and DFA  constructionAutomata theory -- NFA and DFA  construction
Automata theory -- NFA and DFA constructionAkila Krishnamoorthy
 
Intermediate code generation in Compiler Design
Intermediate code generation in Compiler DesignIntermediate code generation in Compiler Design
Intermediate code generation in Compiler DesignKuppusamy P
 
Shortest path algorithm
Shortest path algorithmShortest path algorithm
Shortest path algorithmsana younas
 
Intro automata theory
Intro automata theory Intro automata theory
Intro automata theory Rajendran
 
LINEAR BOUNDED AUTOMATA (LBA).pptx
LINEAR BOUNDED AUTOMATA (LBA).pptxLINEAR BOUNDED AUTOMATA (LBA).pptx
LINEAR BOUNDED AUTOMATA (LBA).pptxAkhilJoseph63
 
Error detection recovery
Error detection recoveryError detection recovery
Error detection recoveryTech_MX
 
Regular language and Regular expression
Regular language and Regular expressionRegular language and Regular expression
Regular language and Regular expressionAnimesh Chaturvedi
 

What's hot (20)

Techniques & applications of Compiler
Techniques & applications of CompilerTechniques & applications of Compiler
Techniques & applications of Compiler
 
Homophonic Substitution Cipher
Homophonic Substitution CipherHomophonic Substitution Cipher
Homophonic Substitution Cipher
 
Dijkstra's Algorithm
Dijkstra's Algorithm Dijkstra's Algorithm
Dijkstra's Algorithm
 
Peephole Optimization
Peephole OptimizationPeephole Optimization
Peephole Optimization
 
SINGLE-SOURCE SHORTEST PATHS
SINGLE-SOURCE SHORTEST PATHS SINGLE-SOURCE SHORTEST PATHS
SINGLE-SOURCE SHORTEST PATHS
 
Lex & yacc
Lex & yaccLex & yacc
Lex & yacc
 
Context Free Grammar
Context Free GrammarContext Free Grammar
Context Free Grammar
 
Lexical analysis - Compiler Design
Lexical analysis - Compiler DesignLexical analysis - Compiler Design
Lexical analysis - Compiler Design
 
Code Optimization
Code OptimizationCode Optimization
Code Optimization
 
TOC 3 | Different Operations on DFA
TOC 3 | Different Operations on DFATOC 3 | Different Operations on DFA
TOC 3 | Different Operations on DFA
 
Automata theory -- NFA and DFA construction
Automata theory -- NFA and DFA  constructionAutomata theory -- NFA and DFA  construction
Automata theory -- NFA and DFA construction
 
Intermediate code generation in Compiler Design
Intermediate code generation in Compiler DesignIntermediate code generation in Compiler Design
Intermediate code generation in Compiler Design
 
Shortest path algorithm
Shortest path algorithmShortest path algorithm
Shortest path algorithm
 
Specification-of-tokens
Specification-of-tokensSpecification-of-tokens
Specification-of-tokens
 
Intro automata theory
Intro automata theory Intro automata theory
Intro automata theory
 
LINEAR BOUNDED AUTOMATA (LBA).pptx
LINEAR BOUNDED AUTOMATA (LBA).pptxLINEAR BOUNDED AUTOMATA (LBA).pptx
LINEAR BOUNDED AUTOMATA (LBA).pptx
 
Syntax analysis
Syntax analysisSyntax analysis
Syntax analysis
 
Error detection recovery
Error detection recoveryError detection recovery
Error detection recovery
 
Regular language and Regular expression
Regular language and Regular expressionRegular language and Regular expression
Regular language and Regular expression
 
String matching algorithms
String matching algorithmsString matching algorithms
String matching algorithms
 

More from Ashik Khan

Online food project
Online food projectOnline food project
Online food projectAshik Khan
 
Set associative mapping
Set associative mappingSet associative mapping
Set associative mappingAshik Khan
 
Travel management system in html 1
Travel management system in html 1Travel management system in html 1
Travel management system in html 1Ashik Khan
 
Dhakavehiclesystem 170417113343.pdf abid
Dhakavehiclesystem 170417113343.pdf abidDhakavehiclesystem 170417113343.pdf abid
Dhakavehiclesystem 170417113343.pdf abidAshik Khan
 
Final project of vehicle system.pdf this is it
Final project of vehicle system.pdf this is itFinal project of vehicle system.pdf this is it
Final project of vehicle system.pdf this is itAshik Khan
 
Final project of vehicle system
Final project of vehicle systemFinal project of vehicle system
Final project of vehicle systemAshik Khan
 
Push down automata
Push down automataPush down automata
Push down automataAshik Khan
 
Turing machine
Turing machineTuring machine
Turing machineAshik Khan
 
vehicle management system project report
vehicle management system project reportvehicle management system project report
vehicle management system project reportAshik Khan
 
vehicle management system project
vehicle management system projectvehicle management system project
vehicle management system projectAshik Khan
 
Srs of dhaka vehicle system
Srs of dhaka vehicle systemSrs of dhaka vehicle system
Srs of dhaka vehicle systemAshik Khan
 

More from Ashik Khan (12)

Online food project
Online food projectOnline food project
Online food project
 
Assignment 01
Assignment 01Assignment 01
Assignment 01
 
Set associative mapping
Set associative mappingSet associative mapping
Set associative mapping
 
Travel management system in html 1
Travel management system in html 1Travel management system in html 1
Travel management system in html 1
 
Dhakavehiclesystem 170417113343.pdf abid
Dhakavehiclesystem 170417113343.pdf abidDhakavehiclesystem 170417113343.pdf abid
Dhakavehiclesystem 170417113343.pdf abid
 
Final project of vehicle system.pdf this is it
Final project of vehicle system.pdf this is itFinal project of vehicle system.pdf this is it
Final project of vehicle system.pdf this is it
 
Final project of vehicle system
Final project of vehicle systemFinal project of vehicle system
Final project of vehicle system
 
Push down automata
Push down automataPush down automata
Push down automata
 
Turing machine
Turing machineTuring machine
Turing machine
 
vehicle management system project report
vehicle management system project reportvehicle management system project report
vehicle management system project report
 
vehicle management system project
vehicle management system projectvehicle management system project
vehicle management system project
 
Srs of dhaka vehicle system
Srs of dhaka vehicle systemSrs of dhaka vehicle system
Srs of dhaka vehicle system
 

Recently uploaded

INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEroselinkalist12
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2RajaP95
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfme23b1001
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxvipinkmenon1
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .Satyam Kumar
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 

Recently uploaded (20)

INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdf
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptx
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 

Removing ambiguity-from-cfg

  • 2. Group Members: 1. Muradul Islam Jamil (152-35-1203) 2. Mahadi Hasan Joy (152-35-1207) 3. Mazed Mourshed (152-35-1215) Md. Anwar Hossen Lecturer, Dept. of Software Engineering Daffodil International University 2
  • 3. AMBIGUITY IN CFG If a context free grammar has more than one derivation tree for some string, it is called an ambiguous grammar. There exist multiple right-most or left-most derivations for some string generated from that grammar. 3
  • 4. PROBLEM Check whether the grammar G with production rules − S → AB | aaB A → a | Aa B → b 4
  • 5. SOLUTION Let’s find out the derivation tree for the string “aab". It has two leftmost deriv i) S → aaB → aab ii) S → AB →AaB → aaB → aab 5
  • 6. ANOTHER PROBLEM Check whether the grammar G with production rules − S → S + S | S * S | a 6
  • 7. SOLUTION Let’s find out the derivation tree for the string “a+a+a". It has two leftmost d i) S → S + S → S + S + S → a + a + S → a + a + a ii) S → S + S → S + S + S → S + a + a → a + a + a 7
  • 8. SOLUTION Let’s find out the derivation tree for the string “a+a*a". It has two leftmost de i) S → S + S → a + S → a + S * S → a + a * a ii) S → S * S → S + S * S → a + a * S → a + a * a 8