Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

50 Tips And Tricks For MongoDB Developers Get The Most Out Of Your Database

Authors: Kristina Chodorow

1st Edition

1449304613, 978-1449304614

More Books

Students also viewed these Databases questions

Question

Rewrite the statement below using if/ else statement z=(a

Answered: 1 week ago