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 : 1961 | Status : [Member] [MVP] | Replies : 1
Hi,

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:

http://www.uploadforever.net/download.php?img=575

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:

Thanks,
Naimish
http://dotnetinterview.zxq.net/
http://naimishpandya.blogspot.in/



Responses

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

Up
0
Down
Hi,

Image Updated.

Thanks :)

Thanks,
Naimish
http://dotnetinterview.zxq.net/
http://naimishpandya.blogspot.in/

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

Login to post response