170801094Ex.no:CONSTRUCTION OF NFA FOR A GIVEN REGULAR EXPRESSIONDate:AIM:To write a c program to construct a NFA for a given regular expression.ALGORITHM:1.Declare a struct called node with node_no, a_count, b_count and node pointersnexta, nextb and nextnode.2.Declare a static variable nodecount.3.Get the regular expression from the user.4.Check each character in the regular expression until the last is reached.5.If the character is ‘(‘, parse the regex till ‘)’ is encountered. If the character is‘a’, assign p->nexta=p and increment a_count. Do the same for ‘b’6.If the character is *, loop the state to itself.7.If the character is ‘a’ or ‘b’, define a new state by creating a temp node andassign the respective pointers.8.Increment the ‘nodecount’ value everytime a new node is created.9.Print the transition table. For each state, print the next states for ‘a’ and ‘b’inputs.10.Stop.CODE:#include<stdio.h>#include<string.h>#include<stdlib.h>int nodecount=0;struct node{struct node *next_node;int node_no;