πŸŽ“ Computer Science & Engineering Portal

Master Engineering Disciplines with Structured Notes

Comprehensive academic lecture notes, exam-oriented unit summaries, laboratory manuals, and previous year question papers designed strictly for university students.

πŸ“‘

University Syllabi

AKTU & AICTE aligned semester guidelines.

πŸ“

Exam Question Papers

Previous 5 years solved university papers.

πŸ’‘

Lab Manuals & Viva

Practical codes with outputs & interview Qs.

Core Subjects & Units Hub

Click on any specific unit to immediately view its lecture notes below

Viewing All Lectures

Right and Left linear Regular Grammars

Regular grammar is a type of grammar that describes a regular language. A regular grammar is a mathematical object, G, which consists of four components, G = (N, E, P, S), where 

  • N: non-empty, finite set of non-terminal symbols,
  • E: a finite set of terminal symbols, or alphabet, symbols,
  • P: a set of grammar rules, each of one having one of the forms
    • A β‡’ aB
    • Aβ‡’ a
    • A β‡’βˆˆ, Here ∈=empty string, A, B ∈ N, a ∈ βˆ‘
  • S βˆˆ N is the start symbol.

This grammar can be of two forms:

  1. Right Linear Regular Grammar
  2. Left Linear Regular Grammar

Right Linear Regular Grammar

In this type of regular grammar, all the non-terminals on the right-hand side exist at the rightmost place, i.e; right ends.

Examples :

A β‡’ a, A β‡’ aB, A β‡’ ∈
where,
A and B are non-terminals,
a is terminal, and
∈ is empty string
S β‡’ 00B | 11S
B β‡’ 0B | 1B | 0 | 1
where,
S and B are non-terminals, and
0 and 1 are terminals

Left Linear Regular Grammar

In this type of regular grammar, all the non-terminals on the right-hand side exist at the leftmost place, i.e; left ends.

Examples :

A β‡’ a, A β‡’ Ba, A β‡’ ∈
where,
A and B are non-terminals,
a is terminal, and
∈ is empty string
S β‡’ B00 | S11
B β‡’ B0 | B1 | 0 | 1
where
S and B are non-terminals, and
0 and 1 are terminals

Left linear to Right Linear Regular Grammar

In this type of conversion, we have to shift all the left-handed non-terminals to right as shown in example given below:

            Left linear            Right linear 
                      
            A -> Ba                     A -> abaB     
            B -> ab                     B -> epsilon   
                                   OR
                                        A -> abB
                                        B -> a

So, this can be done to give multiple answers. Example explained above have multiple answers other than the given once.

Right linear to Left Linear Regular Grammar

In this type of conversion, we have to shift all the right-handed non-terminals to left as shown in example given below:

               Right linear                      Left linear
                     
                 A -> aB                             A -> Baba  
                 B -> ab                             B -> epsilon  
                                                 OR
                                                     A -> Bab
                                                     B -> a

So, this can be done to give multiple answers. Example explained above have multiple answers other than the given once.

Labels: ,

Discussion & Queries (<$I18NNumComments$>):

<$CommentPager$>
<$I18NAtCommentTimeWithPermalink$>, <$I18NCommentAuthorSaid$>

<$BlogCommentBody$>

<$BlogCommentDeleteIcon$>
<$CommentPager$>