[Solved] Determine if there is a path between all vertex pairs on an directed graph

The following algorithm can me implemented with O(N+M) complexity. Take any vertex u. Use flood fill algorithm to reach other vertices. If any vertex is not reachable, return NOK. Now do the same, but go to the opposite direction. If any vertex is not reachable, return NOK. Return OK. (Here we know that there is … Read more

[Solved] Why isn’t length(self.next) a valid expression in python? [closed]

What is length? length does not exist, but Node.length does. The reason return(1+length(self.next)) doesn’t work is because you’re calling length(), not Node.length(). Instead, try this: return(1+LinkedList.length(self.next)) Or this (my preference): return(1+self.next.length()) solved Why isn’t length(self.next) a valid expression in python? [closed]

[Solved] Trouble starting an algorithm [closed]

You will obviously compute the partial sums X.n and stop when X.n<4 and X.n+1>4. To compute the partial sums, keep an accumulator variable and add the fractions one after the other n= 0 S= 0 // Repeat the following instructions n+= 1 S+= 1/(n+1) // Now, S = X.n Remains to find the stopping condition. … Read more