Algorithms and Data Structures · Senior · Question 25 of 75

An interviewer describes a problem that reduces to the traveling salesman problem. What's a sensible response?

Explanation

No polynomial algorithm is known. Exact bitmask DP is O(n² × 2ⁿ), fine up to about 20 cities. For real routes you use heuristics such as nearest neighbor plus 2-opt, or a solver, and accept a near-optimal answer.

Further reading

Problem with a question

Algorithms and Data Structures · Senior · question 25

Test yourself

Take the Algorithms and Data Structures · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz