4
Most read
5
Most read
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

PPT
Code Optimization
PPTX
LINEAR BOUNDED AUTOMATA (LBA).pptx
PPTX
Ambiguty
PPTX
Daa unit 3
PPTX
COMPILER DESIGN
PPT
Network Simulator Tutorial
PDF
Compiler unit 2&3
PPTX
NFA & DFA
Code Optimization
LINEAR BOUNDED AUTOMATA (LBA).pptx
Ambiguty
Daa unit 3
COMPILER DESIGN
Network Simulator Tutorial
Compiler unit 2&3
NFA & DFA

What's hot (20)

PDF
Bottom up parser
PPTX
Turing machine
PPTX
Asymptotic Notation
PPT
Greedy Algorithm
PPTX
Alphabets , strings, languages and grammars
PPTX
5-Introduction to Parsing and Context Free Grammar-09-05-2023.pptx
PPT
UNIT-1-PPTS-DAA.ppt
PPTX
Finite Automata in compiler design
PPTX
Pipeline hazards | Structural Hazard, Data Hazard & Control Hazard
PDF
Syntax analysis
DOCX
Advanced data structures & algorithms important questions
PPTX
Asymptotic Notation and Data Structures
PPTX
push down automata
PPTX
Top down parsing
PDF
Introduction to algorithms
PPTX
2.5 ambiguity in context free grammars
PPTX
Context free grammar
PDF
Deterministic Finite Automata (DFA)
PPTX
Superscalar & superpipeline processor
PPTX
Ambiguous & Unambiguous Grammar
Bottom up parser
Turing machine
Asymptotic Notation
Greedy Algorithm
Alphabets , strings, languages and grammars
5-Introduction to Parsing and Context Free Grammar-09-05-2023.pptx
UNIT-1-PPTS-DAA.ppt
Finite Automata in compiler design
Pipeline hazards | Structural Hazard, Data Hazard & Control Hazard
Syntax analysis
Advanced data structures & algorithms important questions
Asymptotic Notation and Data Structures
push down automata
Top down parsing
Introduction to algorithms
2.5 ambiguity in context free grammars
Context free grammar
Deterministic Finite Automata (DFA)
Superscalar & superpipeline processor
Ambiguous & Unambiguous Grammar
Ad

Similar to Removing ambiguity-from-cfg (20)

PPTX
L11 context-free grammers 2.pptx parse tree
PPTX
chapter 4 context-freegrammarintroduction context-freegramma
PPTX
Lefmost rightmost TOC.pptx
PPT
Ambiguous and Unambiguous Grammar and MFC
PPTX
AUTOMATA AUTOMATA AUTOMATA Automata6Chapter5.pptx
PPTX
ContextFreeGrammars.pptx
PPTX
ContextFreeGrammars (1).pptx
PPTX
Theory of computation Lec6
PPTX
compiler design syntax analysis top down parsing
PPTX
Context free grammar
DOCX
Context Free Grammer .docx
PPTX
6-Role of Parser, Construction of Parse Tree and Elimination of Ambiguity-06-...
PPT
Unit-2 Context free grammer. ppt CFG CFL
PDF
TOC 8 | Derivation, Parse Tree & Ambiguity Check
PPTX
CONTEXT FREE GRAMMAR
PPT
Context free grammer.ppt
PDF
cfl2.pdf
PPTX
Derivation of Context Free Grammars (CFG)
L11 context-free grammers 2.pptx parse tree
chapter 4 context-freegrammarintroduction context-freegramma
Lefmost rightmost TOC.pptx
Ambiguous and Unambiguous Grammar and MFC
AUTOMATA AUTOMATA AUTOMATA Automata6Chapter5.pptx
ContextFreeGrammars.pptx
ContextFreeGrammars (1).pptx
Theory of computation Lec6
compiler design syntax analysis top down parsing
Context free grammar
Context Free Grammer .docx
6-Role of Parser, Construction of Parse Tree and Elimination of Ambiguity-06-...
Unit-2 Context free grammer. ppt CFG CFL
TOC 8 | Derivation, Parse Tree & Ambiguity Check
CONTEXT FREE GRAMMAR
Context free grammer.ppt
cfl2.pdf
Derivation of Context Free Grammars (CFG)
Ad

More from Ashik Khan (12)

PDF
Online food project
PDF
Assignment 01
PPTX
Set associative mapping
PDF
Travel management system in html 1
PDF
Dhakavehiclesystem 170417113343.pdf abid
PDF
Final project of vehicle system.pdf this is it
DOCX
Final project of vehicle system
PPTX
Push down automata
PPTX
Turing machine
DOCX
vehicle management system project report
PPTX
vehicle management system project
DOCX
Srs of dhaka vehicle system
Online food project
Assignment 01
Set associative mapping
Travel management system in html 1
Dhakavehiclesystem 170417113343.pdf abid
Final project of vehicle system.pdf this is it
Final project of vehicle system
Push down automata
Turing machine
vehicle management system project report
vehicle management system project
Srs of dhaka vehicle system

Recently uploaded (20)

PPTX
Design ,Art Across Digital Realities and eXtended Reality
PDF
AIGA 012_04 Cleaning of equipment for oxygen service_reformat Jan 12.pdf
PDF
Unit1 - AIML Chapter 1 concept and ethics
PPTX
Environmental studies, Moudle 3-Environmental Pollution.pptx
PDF
UEFA_Carbon_Footprint_Calculator_Methology_2.0.pdf
PDF
Beginners-Guide-to-Artificial-Intelligence.pdf
PPTX
BBOC407 BIOLOGY FOR ENGINEERS (CS) - MODULE 1 PART 1.pptx
PPTX
Solar energy pdf of gitam songa hemant k
PPTX
SE unit 1.pptx aaahshdhajdviwhsiehebeiwheiebeiev
PPTX
AI-Reporting for Emerging Technologies(BS Computer Engineering)
PDF
August -2025_Top10 Read_Articles_ijait.pdf
PPTX
Agentic Artificial Intelligence (Agentic AI).pptx
PDF
Principles of operation, construction, theory, advantages and disadvantages, ...
PDF
[jvmmeetup] next-gen integration with apache camel and quarkus.pdf
DOCX
ENVIRONMENTAL PROTECTION AND MANAGEMENT (18CVL756)
PDF
Lesson 3 .pdf
PPTX
CT Generations and Image Reconstruction methods
PPT
UNIT-I Machine Learning Essentials for 2nd years
PPTX
Cisco Network Behaviour dibuywvdsvdtdstydsdsa
PPTX
Environmental studies, Moudle 3-Environmental Pollution.pptx
Design ,Art Across Digital Realities and eXtended Reality
AIGA 012_04 Cleaning of equipment for oxygen service_reformat Jan 12.pdf
Unit1 - AIML Chapter 1 concept and ethics
Environmental studies, Moudle 3-Environmental Pollution.pptx
UEFA_Carbon_Footprint_Calculator_Methology_2.0.pdf
Beginners-Guide-to-Artificial-Intelligence.pdf
BBOC407 BIOLOGY FOR ENGINEERS (CS) - MODULE 1 PART 1.pptx
Solar energy pdf of gitam songa hemant k
SE unit 1.pptx aaahshdhajdviwhsiehebeiwheiebeiev
AI-Reporting for Emerging Technologies(BS Computer Engineering)
August -2025_Top10 Read_Articles_ijait.pdf
Agentic Artificial Intelligence (Agentic AI).pptx
Principles of operation, construction, theory, advantages and disadvantages, ...
[jvmmeetup] next-gen integration with apache camel and quarkus.pdf
ENVIRONMENTAL PROTECTION AND MANAGEMENT (18CVL756)
Lesson 3 .pdf
CT Generations and Image Reconstruction methods
UNIT-I Machine Learning Essentials for 2nd years
Cisco Network Behaviour dibuywvdsvdtdstydsdsa
Environmental studies, Moudle 3-Environmental Pollution.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