Could you please elaborate on O(n+m) algorithm that you have used On Oct 12, 6:43 pm, ligerdave <[email protected]> wrote: > sorting is absolutely required. w/o the sorting, how are you going to > find the min? comparison is also a sorting algorithm. > it also depends on how many suggestions you wanna have. if it's just > the best deal, you can complete this in O(n+m) where n is the number > of different fares of trip to and m is the trip back > > On Oct 12, 9:06 am, Amod <[email protected]> wrote: > > > > > > > > > Suppose there are 100 flights from A to B and 1000 flights from B to > > A. > > Now a user selects the round trip from A to B and back to A, the site > > presents suggestions based on the least fare of the return journey. > > Could someone please help me to device and algorithm where based on > > number of suggestions the results are displayed. > > ex > > A->B B->A > > A1 1 B1 1 > > A2 2 B2 3 > > A3 4 B3 5 > > A4 6 B4 8 > > > So if i want four suggestions then A1+B1, A2+B1, A1+B2, A2+B2 > > > Please also suggest whether sorting based on fares is required or not
-- 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.
