Question: I am working on an NFA program in Go called reachable. Reachable returns true if there exists a sequence of transitions from `transitions` such that

I am working on an NFA program in Go called reachable. Reachable returns true if there exists a sequence of transitions from `transitions` such that if the NFA starts at the start state /`start` it would reach the final state `final` after reading the entire sequence of symbols `input` otherwise return false.

I have implemted the function, and it works. But now I need to make it concurrent. I belive that the keywork go would be at the start function call.

So I basically need a way for each thread to signal to the main thread if it succeeded. Channels would most likely be the asnwer. In your answer please make sure you are making sure it is concurrent for a thumbs up.

func Reachable( transitions TransitionFunction, start, final state, input []rune ) bool {

var wg sync.WaitGroup

var flag bool if len(input)==0 {

if start == final{ return true }else{ return false } }

var nextState = transitions(start, input[0])

for i := 0 ; i

if flag || go Reachable(transitions, nextState[i], final, input[1:]){

return true } } return flag }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!