Top. Sort gives you an ordering a1, a2, ..., an such that when you calculating a[i], you have calculated a[j] for all j>i before. (Note that all the neighbors of a[i] has a bigger index.) So, there's no need to memoize them and write e function, you can just do it in a loop.
--Nima On Fri, Aug 28, 2009 at 12:34 PM, manish bhatia <[email protected]>wrote: > How should a toposort help? > > ------------------------------ > *From:* ankur aggarwal <[email protected]> > *To:* [email protected] > *Sent:* Thursday, 27 August, 2009 9:15:47 AM > *Subject:* [algogeeks] Re: path from n1 to n2 > > @ >> _dufus >> >> i also think dfs can solve this problem widout topological sort >> >> > > ------------------------------ > Love Cricket? Check out live scores, photos, video highlights and more. Click > here <http://in.rd.yahoo.com/tagline_cricket_2/*http://cricket.yahoo.com>. > > > -- Nima Aghdaii "The ideal situation occurs when the things that we regard as beautiful are also regarded by other people as useful." -Donald Knuth- --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
