- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# How to convert FA to Right Linear Regular Grammar?

A grammar with at most one variable at the right side of production is called linear grammar.

## Example 1

S→aSb/ε

## Example 2

S→Ab

A→aAb

A→ε

## Right Linear Grammar

A grammar is right linear grammar where all the non terminals in the right hand sides are at the right end.

For example,

S->aS/ε

## Algorithm for conversion

The algorithm to convert the finite automata (FA) to the right linear grammar is as follows −

Step 1 − Begin the process from the start state.

Step 2 − Repeat the process for each state.

Step 3 − Write the production as the output followed by the state on which the transition is going.

Step 4 − And at last, add € (epsilon) to end the derivation.

## Example 1

Let’s consider a Finite automaton (FA) as given below −

Pick the start state A and output is on symbol ‘a’ going to state B

A→aB

Now we will pick state B and then we will go on each output

i.e B→aB

B→bB

B→ε

Therefore,

Final right linear grammar is as follows −

A→aB

B→aB/bB/ε

## Example 2

Start with state A which is an initial state the output on symbol ‘a’ goes to A and B and the output on symbol ‘b’ goes to A. Now the production rule of right linear grammar is −

A→aA/bA/aB

Now pick state B and then go on each output the right linear grammar is −

B→aB/bB/ε

The final right linear grammar for the given finite automata is −

A→aA/bA/aB

B→aB/bB/ε

- Related Questions & Answers
- How to convert right linear grammar to left linear grammar?
- How to convert left linear grammar to right linear grammar?
- How to convert FA to Left Linear Grammar in TOC?
- Explain about left linear regular grammar in TOC
- Explain about right linear regular grammars in TOC
- How to convert context free grammar to push down automata?
- How to convert Regular expression to Finite Automata?
- Convert the given Context free grammar to CNF
- What are the restrictions of regular grammar?
- How can we convert subqueries to RIGHT JOIN?
- How to convert the finite automata into regular expressions?
- How to Convert Perl Compatible Regular Expressions (PCRE) into Lua
- Explain Arden’s theorem to convert DFA to Regular Expression
- How to generate the language for context free grammar?
- How to handle right-to-left and left-to-right swipe gestures on Android?