- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Find the canonical collection of sets of LR (0) items for Grammar -
E → E + T
E → T
T → T * F
T → F
F → (E)
F → id
Solution
Step1− Construct the Augmented Grammar and number the productions
(0) E′ → E
(1) E → E + T
(2) E → T
(3) T → T * F
(4) T → F
(5) F → (E)
(6) F → id
Step2− Apply closure to the set of items & find goto
Square Boxes represent the new states or items, and Circle represents the repeating items.
So, all rules of I0have been completed by applying goto on I0. Now, in the same manner apply goto on I1, I2 and then goes on.
Drawing DFA
Each set of the item can be taken as a state of DFA, i.e., I0, I1 … … I11will be 11 states of DFA. They are connected using a goto function.
For example, As goto (I0, E) = I1.
∴ There will be an edge from state I0 to I1..
Advertisements