2014-05-08 23:45
原题:
How would you use Dijkstra's algorithm to solve travel salesman problem, which is to find a shortest path from a starting node back to the starting node and visits all other node exactly once.
题目:如何用Dijkstra算法来解决TSP问题?(谁会出这种题,这又是“Guy”从哪儿copy来的?)
解法:对于这种问题我不知道该说什么。一个多项式级别的算法来解决NP问题,这已经超出了面试题或者教科书的范畴吧?这个“Guy”自己写的代码都够呛,还能问别人这种问题,实在让人无力吐槽。Dijkstra算法用于解决单源最短路径问题,而且要求没有负权的边。就算是用其他算法来近似最优解,也应该用类似最小生成树的算法吧。所以我觉得这个“Guy”应该被永久禁止发帖,完全是在误导我们这些辛辛苦苦做面试题的人。找个工作容易吗?
代码:
// http://www.careercup.com/question?id=5085331422445568
// Answer:
// Dijkstra Algorithm is not for TSP, why would you expect to solve NP-hard problems with O(n ^ 2) efforts?
// Comment:
// 1. Difficult question.
// 2. Vague description.
// 3. Strange indication.
// 4. Stupid discussion.
// Based on the judgement above, I believe that 'guy' is a complete amateur. Excellent programmers don't ask stupid questions, but he did.
// The reason I'm complaining is that, he pretended to have google interview experience and posted a lot of fake questions only to trick us.
// He doesn't even know how to calculate the distance between two points?
// He doesn't know what volatile means.
// He keeps asking stupid questions.
// SO HOW THE HELL DOES THIS 'GUY' HAVE SO MANY GOOGLE INTERVIEWS?
// He's site reliability engineer at Boeing, really?
// I hate liars, especially foolish liars!
// Down vote for every question he posted.
int main()
{
return ;
}