C++ CODE:
******************************************************
#include <bits/stdc++.h>
using namespace std;
int countSubstringWithEqualEnds(string s)
{
int result = 0;
int n = s.length();
// Iterating through all substrings in
// way so that we can find first and last
// character easily
for (int i=0; i<n; i++)
for (int j=i+1; j<n; j++)
if (s[i] == s[j]) {
if(s[i] == 'A' || s[i] == 'T'){
result++;
for(int k=i;k<=j;k++){
cout << s[k];
}
cout << endl;
}
}
// result++;
return result;
}
// Driver function
int main()
{
string s;
cin >> s;
cout << "Total DFA matched strings::"<<
countSubstringWithEqualEnds(s);
return 0;
}
***********************************************************************************************
OUTPUT:
THANK YOU
In this assignment, you wil implement a deterministic finite automata (DFA) using C++ programming...
Implement a deterministic finite automata (DFA) using C++ programming language to extract matching patterns from a given input DNA sequence string. Design a deterministic finite automata to recognize the regular expression A(A+T+G+C)*A + T(A+T+G+C)*T over the alphaber {A,T,G,C}. This regular expression recognize any string that starts and ends with ‘A’ or starts and ends with ‘T’. Write a program which asks the user to input a DNA sequence. The program should be able to extract all the patterns (substrings present...
In this assignment, you will implement a deterministic finite automata (DFA) using C++ programming language to extract all matching patterns (substrings) from a given input DNA sequence string. The alphabet for generating DNA sequences is {A, T, G, C}. Write a regular expression that represents all DNA strings that contains at least two ‘A’s. Note: assume empty string is not a valid string. Design a deterministic finite automaton to recognize the regular expression. Write a program which asks the user...
Write a class for DFA type objects. Deterministic Finite Automata are commonly defined as a quintuple consisting of a set of states, a set of symbals, a transition function, a start state and a set of accept states For this implementation let the alphabet be given as a string of symbols, the transition function as list of lists which represent an n by m matrix where the n rows represent the states and the m columns represent the alphabet symbols,...
Given the following non-deterministic finite state machine: (c) a σ0 o1 σ2 b Find the input set V, the accepting states set T, the states set S, and initial (i) state for the machine. (10/100) Write the transition table for the machine (ii) (10/100) (iii) Write the simplest phrase structure grammar, G=(V,T,S,P), for the machine (10/100) Rewrite the grammar you found in question 4(c)(iii) in BNF notation (iv) (10/100) (v) Is the string aabaaba an accepted string by the finite-state...
Automata: solve a - e 2. (10+10+10+10+10-50 points) Agrammar is a 4-tuple G, G-ON,E,11,L$) where N is a finite set of nonterminal symbols Σ is a finite set of terminal symbols is a finite set of rules S is the starting symbol Let N- (S, T s-{a, b, c} s-> ab aT >aaTb aT-ac S is the starting symbol. (a 10 points) Prove that the given grammar G is a context sensitive grammar. (b-10 points) What is the language L-...
Show that L = {anbm : m ≥ n +3} is deterministic. This is for formal languages and automata... Can you please try to explain what you are doing and why (if necessary, if not ill try my best to figure it out.) The definitions i'm working based off of are posted as a image below. Thanks! DEFINITION 7.3 A pushdown automaton M-О. Е, Г, 0, qo, z, Fİs said to be deterministic ifit is an automaton as defined in...
IMPLEMENT IN C++ Implement a symbol balance checker function for the Pascal programming language. Pascal allows for the following pairs: {}, (), [], begin end . All programs will begin with the word "begin" and end with the word "end". Your function should receive an ifstream object which is already open and will return true, all of the symbols match, or false, they do not. You do not have to worry about comments in the program but you do have...
Stacks and Java 1. Using Java design and implement a stack on an array. Implement the following operations: push, pop, top, size, isEmpty. Make sure that your program checks whether the stack is full in the push operation, and whether the stack is empty in the pop operation. None of the built-in classes/methods/functions of Java can be used and must be user implemented. Practical application 1: Arithmetic operations. (a) Design an algorithm that takes a string, which represents an arithmetic...
In C Programming Language In this lab you will implement 4 string functions, two using array notation and two using pointers. The functions must have the signatures given below. You may not use any C library string functions. The functions are 1. int my strlen (char s ) - This function returns the number of characters in a string. You should use array notation for this function. 2. int my strcpy (char s [], char t I)- This function overwrites...