What about this:

First you have the list of distances between two milestones. Let’s form a
table

Start milestone

End Milestone

Distances

A1

A0

7

A0

A3

10

A1

A2

5

A2

A3

2

A0

A2

8

A0

A1

3



I have taken above variable A0, A1, A2, A3 for a, b, c, d respectively. Now
we sort the first column. If we find two entries same then sort also on
based on second column.

After processing you will get the following table

Start milestone

End Milestone

Distances

A0

A1

3

A0

A2

8

A0

A3

10

A1

A0

7

A1

A2

5

A2

A3

2



When you get this table:

1)      Start with A0 and search for next milestone which is A1. Add this to
your milestone list or just print.

2)      Move to A1 in the first column and add the first entry which does
not contains previously visited milestone. That is A2 whose distance is 5.
You cannot add A1-A0 since it is already visited.

3)      Repeat the above process till the end of list in table. Now
following this step you come to A2 and you add A3 in the milestone list
whose distance is 2.

4)       Now you get the list of milestone…and distances. Output you get is
3-5-2 or 2-5-3.

I hope this will work.



Best Wishes
Sachin Sharma | Software Trainee | Information Mosaic
New York | Dublin | London | Luxembourg | New Delhi | Singapore | Melbourne
|
e-mail: [email protected]
Web:www.informationmosaic.com<http://www.informationmosaic.com/> |  t:
www.twitter.com/infomosaic
Winner 2009 Banking Technology Readers' Choice Award for Best Corporate
Actions Automation Solution

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to