Is there a typical state machine implementation pattern?

We need to implement a simple state machine in C. Is a standard switch statement the best way to go? We have a current state (state) and a trigger for the transition. switch(state) { case STATE_1: state = DoState1(transition); break; case STATE_2: state = DoState2(transition); break; } … DoState2(int transition) { // Do State Work … Read more

Can regular expressions be used to match nested patterns? [duplicate]

This question already has answers here: Regular expression to match balanced parentheses (21 answers) Closed 2 years ago. Is it possible to write a regular expression that matches a nested pattern that occurs an unknown number of times? For example, can a regular expression match an opening and closing brace when there are an unknown … Read more

is it possible to know if a language is regular if its equivalence classes are finite?

i have a theoretical questions, and was wondering if you could help me with it so i could understand the material better. 1)suppose we have some language L over Σ, can we know if L is regular if all of it equivalence classes of relation RL is finite? 2)and what about L*? is it finite? … Read more

Construct context-free grammars that generate for the languages L(G) = {01(110)^n 10 (11)^n : n >= 0}

I have given this question as home assignment. I tried a lot to solve it but couldn’t found any solution. Please help Thanks in Advance! Answer Hint, the grammar S→aSc∣b generates the language {anbcn:n≥0}. Can you you adapt this? Do you understand why it generates that language? AttributionSource : Link , Question Author : Junaid … Read more

RO turing machine with finite memory

Consider the following: A weak TM is a TM with finite tape in size k which can only read its input values. note: the tape size does not include the input length. I need to determine whether if the weak model is equivalent to a regular TM, or to explain why not and to show … Read more

Algorithm for DFA accepting any string with ending with a particular substring

Is there any possible general algorithm for constructing a DFA such that it accepts any string, which has a given sub-string in the suffix(end) for any given language. The algorithm should directly construct the DFA transitions, and not create an NFA first and then convert it to a DFA. In other words, the algorithm accepts … Read more

State-elimination on FSA, after epsilon-removal construction

I want to define the language of this FSA with a regular expression. I have learned that by state-elimination, I would be able to find a regular expression. But there are already some epsilon transitions in this FSA. My question is: Should I first follow the epsilon-removal construction, and then do state elimination? Or can … Read more