TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

Automata Derivation Tree

Automata Derivation Tree with automata tutorial, finite automata, dfa, nfa, regexp, transition diagram in automata, transition table, theory of automata, examples of dfa, minimization of dfa, non deterministic finite automata, etc.

<< Back to AUTOMATA

Derivation Tree

Derivation tree is a graphical representation for the derivation of the given production rules for a given CFG. It is the simple way to show how the derivation can be done to obtain some string from a given set of production rules. The derivation tree is also called a parse tree.

Parse tree follows the precedence of operators. The deepest sub-tree traversed first. So, the operator in the parent node has less precedence over the operator in the sub-tree.

A parse tree contains the following properties:

  1. The root node is always a node indicating start symbols.
  2. The derivation is read from left to right.
  3. The leaf node is always terminal nodes.
  4. The interior nodes are always the non-terminal nodes.

Example 1:

Production rules:

E = E + E
E = E * E
E = a | b | c

Input

a * b + c

Step 1:

Derivation Tree

Step 2:

Derivation Tree

Step 2:

Derivation Tree

Step 4:

Derivation Tree

Step 5:

Derivation Tree

Note: We can draw a derivation tree step by step or directly in one step.

Example 2:

Draw a derivation tree for the string "bab" from the CFG given by

S → bSb | a | b

Solution:

Now, the derivation tree for the string "bbabb" is as follows:

Derivation Tree

The above tree is a derivation tree drawn for deriving a string bbabb. By simply reading the leaf nodes, we can obtain the desired string. The same tree can also be denoted by,

Derivation Tree

Example 3:

Construct a derivation tree for the string aabbabba for the CFG given by,

S → aB | bA
A → a | aS | bAA
B → b | bS | aBB

Solution:

To draw a tree, we will first try to obtain derivation for the string aabbabba

Derivation Tree

Now, the derivation tree is as follows:

Derivation Tree

Example 4:

Show the derivation tree for string "aabbbb" with the following grammar.

S → AB | ε
A → aB
B → Sb

Solution:

To draw a tree we will first try to obtain derivation for the string aabbbb

Derivation Tree

Now, the derivation tree for the string "aabbbb" is as follows:

Derivation Tree




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf