Write an algorithm that will sort the array of paths in ascending order of their costs - Question 4

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

This is Part 4 (Last Part)

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.

4. Each node in figure 1 represents a country in which an international phone call, from country A, can be switched until it reaches its country of destination J. The valid paths represent a list of routes through which a phone call from A to J can be routed. The cost of traversing a node, that is, switching a call to another country, is Rs. 200 per call whereas the cost of using the wiring between any two countries is proportional to the distance between them - if the distance between A and B is 1000km, the cost of using the wiring is Rs. 1000. Using the array of paths and the PathLength attribute of each path, write an algorithm that will sort the array of paths in ascending order of their costs.

If anyone can answer this please:


Posted by: Naimishforu on: 2/14/2011 [Member] [MVP] Bronze | Points: 25


Image Updated.

Thanks :)

Naimishforu, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response