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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started