The distance, d, between two nodes can be obtained by - Question 3

Posted by Naimishforu under Interview Questions on 2/10/2011 | Points: 10 | Views : 2210 | Status : [Member] [MVP] | Replies : 0

This is Part 3

Recently I had been interviewed internationally!!!!! It would be very much helpful if you can also try to solve this "things".

Please first examine the below image:

Figure 1 shows a set of nodes that are labeled from A to J. The position of each node can be defined by the x, y coordinate system. The dotted segments joining the nodes A, B, E, F, I and J, shows a possible path from A to J through the nodes B, E, F and I.

3. The distance, d, between two nodes can be obtained by:

Modify your classes so that:

i. one of them contains the function Distance which takes one (or more) parameter(s) to calculate the distance, d, between two nodes indicating the parameter(s) taken by the function

ii. one of them has the attribute PathLength which is the length of the path from A to J

Give an implementation of the function Distance that takes the parameter(s) you indicated above and returns the distance, d, between two nodes, in an object oriented language (Java, VB.NET, C#, etc) best known to you.

Write an algorithm that will calculate PathLength for all the paths in the array you obtained in question one.

If anyone can answer this please:




(No response found.)

Login to post response