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 compute(startNodeId, 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 #2(or any other
node) is node #5.
fromIds and tolds are two arrays of the same length which describe the one-way
links of the network (fromIds [i] is linked to tolds (11).
In the example above, fromIds is:
11,7,3,4,2,6,9]
and tolds is:
[3,3,4,6,6,9,5]
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:
1

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!