- Trending Categories
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
Explain the concept of derivation in TOC
Derivation is a sequence of production rules. It is used to get input strings. During parsing, we have to take two decisions, which are as follows
- We have to decide the non-terminal which is to be replaced.
- We have to decide the production rule by which the non-terminal will be replaced.
Two options to decide which non-terminal has to be replaced with the production rule are as follows −
- Left most derivation
- Right most derivation.
Let us understand these two options in detail.
Left Most Derivation
In the leftmost derivation, the input is scanned and then replaced with the production rule from left side to right. So, we have to read that input string from left to right.
Example
Production rules:
E=E+E rule1 E=E-E rule2 E=a|b rule3
Let the input be a-b+a
Now, when we perform the Left Most Derivation, the result will be as follows −
E=E+E E=E-E+E from rule2 E=a-E+E from rule3 E=a-b+E from rule3 E=a-b+a from rule3 Finally, the given string is parsed
Right Most Derivation
In Right most derivation, the input is scanned and replaced with the production rule right to left. So, we have to read the input string from right to left.
Example
Production rule:
E=E+E rule1 E=E-E rule2 E=a|b rule3
Let the input be a-b+a
Now, when we perform the Right Most Derivation, we get the following result −
E=E-E E=E-E+E from rule1 E=E-E+a from rule3 E=E-b+a from rule3 E=a-b+a from rule3
- Related Articles
- Explain the concept of grammar in TOC
- Explain the concept of set in TOC?
- Explain the concept of strings in TOC?
- Explain the concept of state elimination method in TOC
- What is a Derivation tree in TOC?
- Explain the derivation of Snell's Law.
- Explain the concept of amalgamation
- Explain the power of an alphabet in TOC.
- Explain the various applications of automata in TOC
- Explain the concept of depreciation in accounting.
- Explain the concept of depletion in accounting.
- Explain the concept of delegates in C#
- Explain the concept of takeover in business
- Explain the concept of Normalization in DBMS?
- Explain the concept of recoverability in DBMS
