teja.1305
BAN USER
Comments (3)
Reputation 0
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
Can't it be done using all pairs shortest paths problem in graph?
Initially take all edges to be of length 1 as in the given example.
Instead of taking min(D[i,j],D[i,k]+D[k,j]), take min(PRICE(D[i,j]),PRICE(D[i,k]+D[k,j])), take the price of that length rather than just length and do it. Somone please say if I'm wrong
Comment hidden because of low score. Click to expand.
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
The another solution doesn't make sense as I see it. First of all how'd you construct a tree where the number of children are not specified? There are methods definitely but then they would take more time not linear. Correct me if I'm wrong
- teja.1305 August 07, 2012