Questions tagged [nfa]

An NFA is a nondeterministic finite automaton, a mathematical model of computation that decides membership in regular languages.

An NFA is a nondeterministic finite automaton, a mathematical model of computation that decides membership in regular languages.

It is similar to a DFA except that it is nondeterministic, and the machine can be in multiple states simultaneously. Some definitions of NFAs also allow for e-moves, in which the automaton can transition between states on no input at all.

It is known that for every NFA there is also DFA that expect the same language, thus their computation streangh is identical.

310 questions
3
votes
5 answers

Shortest string matching multiple wildcard expressions

I have multiple wildcard expressions like: *a*b* *c*d* *e*?* where * means 0 or more letters (they can be any letters, not necessarily the same) ? means single occurance of any letter I need to find shortest string matching those wildcard…
Bojan Vukasovic
  • 2,054
  • 22
  • 43
3
votes
3 answers

Advantages/Disadvantages of NFA over DFA and vice versa

What are the relative pro's and con's of both DFA's and NFA's when compared to each other? I know that DFA's are easier to implement than NFA's and that NFA's are slower to arrive at the accept state than DFA's but are there any other explicit, well…
user559142
  • 12,279
  • 49
  • 116
  • 179
3
votes
1 answer

Is this transformation from a NFA to a DFA correct?

I am studying for an exam and came up to this task in the picture usually the transformation from a NFA to a DFA is easy to me. I create a transition table from the NFA and for every "new" combined state, i create a new column and so on (looking at…
ArdianH101
  • 55
  • 5
3
votes
1 answer

Algorithm - KMP prefix table: is it possible there are two choices to jump to?

Given a pattern abababc, the prefix table is [0,0,1,2,3,4,0]. However, at ababab, both abab and ab are prefixes. Why do we only consider abab as a valid prefix? +---+----------+-------+--------+ | i | P[i] | [i] | Prefix…
3
votes
2 answers

NFA pros and cons compared to DFA?

NFA advantages over a DFA: the representation uses less memory. NFA disadvantages compared to an NFA: Slower to arrive at an answer. Are there any other advantages or disadvantages?
crowso
  • 2,049
  • 9
  • 33
  • 38
3
votes
1 answer

data structure for NFA representation

In my lexical analyzer generator I use McNaughton and Yamada algorithm for NFA construction, and one of its properties that transition form I to J marked with char at J position. So, each node of NFA can be represented simply as list of next…
S.J.
  • 133
  • 6
3
votes
2 answers

If a language (L) is recognized by an n-state NFA, can it also be recognized by a DFA with no more than 2^n states?

I'm thinking so, because the upper bound would be the 2^n, and given that these are both finite machines, the intersection for both the n-state NFA and the DFA with 2^n or less states will be valid. Am I wrong here?
John
  • 31
  • 2
3
votes
1 answer

Parallel regex matching with NFA vs DFA? Which one is faster?

I was reading about NFA and DFA and it seems that the most popular and fastest way of implementing regex matcher is to create NFA from regex, convert it to DFA, minimize that DFA, implement it in any language and use it. DFA is a better choice over…
Dennis Grinch
  • 353
  • 3
  • 13
3
votes
1 answer

Efficient matching of text messages against thousands of regular expressions

I am solving a problem where I have text message to match with thousands of regular expressions of the form {0 or 300 chars} {0 or 300 chars} e.g. "on"[ \t\r]*(.){0,300}"."[ \t\r]*(.){0,300}"from" or a real example can…
Aryaveer
  • 943
  • 1
  • 12
  • 27
3
votes
3 answers

Finite Automata Library written in F#

Could you recommend an open source library written in F# which provides generic types for FA construction and basic algorithms (NFA to DFA transformation, FA minimization ...)?
gsv
  • 277
  • 1
  • 9
3
votes
2 answers

Why use NFAs over DFAs

I'm studying some theory of computation at the moment and, as is implied, it is very theoretical. I can convert from regex to NFAs to DFAs pretty easily, I can understand that. But since all NFAs can be converted to DFAs and (I'm pretty sure) grep…
Greg Peckory
  • 7,700
  • 21
  • 67
  • 114
3
votes
1 answer

NFA to DFA conversion with multiple start states

So I can take a given NFA with a single start state and convert it into an equivalent DFA quite easily, however I'm stumped when it comes to an NFA with multiple start states. Since a DFA can only have one start state (if I'm correct) how do I know…
fletch254
  • 85
  • 1
  • 8
3
votes
1 answer

Defining a graph node variant with cycles in OCaml

I am trying to implement a regex to NFA converter. I have most of the code written, but I am struggling to find a way to build a graph with a cycle given my representation for states (nodes) and edges. My graph representation is as follows: type…
3
votes
2 answers

Steps to draw a DFA (or NFA) from a simple statement?

I am given a simple statement: Construct a DFA over alphabet {0, 1} that accepts all the strings that end in 101? My question is that what will be the steps to design it? Or design an NFA, because then I know the clear steps yo convert an NFA to a…
Solace
  • 8,612
  • 22
  • 95
  • 183
3
votes
2 answers

How exactly do the lazy quantifiers work in PCRE?

A bit of background: I'm implementing a regex matching engine (NFA) and it should support PCRE compatibility mode (I mean it should capture subexpressions with the same offsets as PCRE would do). There's a test in PCRE's testinput1 which I can't…