Following up the question from the pre-exam-tirgul earlier today:

given a language L, we define Sub(L) = {y | xyz in L} i.e. all the continuous substrings of words in L

Here is the construction of an NFA N for Sub(L) given a DFA D for L:

1. First we remove from D all states that are unreachable and all states that are not part of an accpeting path (and all related transitions) - this results in an NFA N' that also accepts the same language L. Now,

2. We add a new initial state i and epsilon transitions form i to each state of N' (this is equivalent to "guessing" x in the definition above)

3. We add a new accepting state a and epsilon transitions form each state of N' to a (this is equivalent to "guessing" z in the definition above)

Thats it!