Question: Implement the function compute ( startNodeId , fromIds, tolds ) which should retum the last node id of the network found when starting from the
Implement the function computestartNodeId fromIds, tolds which should
retum the last node id of the network found when starting from the node with id startNodeId and following the links of the network.
In the above example, the endpoint node when starting from node #or any other
node is node #
fromIds and tolds are two arrays of the same length which describe the oneway
links of the network fromIds i is linked to tolds
In the example above, fromIds is:
and tolds is:
In case you run into a loop when traversing the network, the function should retum the id of the last node traversed before closing the loop.
Constraints:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
