Pearson Edexcel · A-Level · Mathematics

    Course version: 603/1499/0 · Version from Sept 2017

    Decision Mathematics 1: 3.2 The nearest neighbour algorithm.

    Full specification wording

    Algorithms on graphs II - Paper 3D: Decision Mathematics 1: 3.2 The nearest neighbour algorithm.

    The nearest neighbour algorithm builds a tour by starting at a chosen vertex, then repeatedly moving to the nearest unvisited vertex until all vertices are visited, finally returning to the start.

    • Point 5 of 5

    Study notes

    From the teaching notes for this specification point.

    The idea

    The nearest neighbour algorithm builds a tour by starting at a chosen vertex, then repeatedly moving to the nearest unvisited vertex until all vertices are visited, finally returning to the start. Each step selects the smallest available edge weight to an unvisited vertex, so the method is quick but greedy and rarely optimal. Running it from every possible starting vertex and taking the cheapest resulting tour improves the result and gives an upper bound on the optimal travelling salesperson tour. Record the order of vertices visited and the running total of weights, and remember to add the closing edge back to the start. The algorithm never revisits a vertex until the final return.

    What earns the marks

    • Starts at a specified vertex and selects the nearest unvisited vertex at each stage.
    • Records the order of visited vertices and accumulates edge weights as the tour develops.
    • Adds the closing edge returning to the starting vertex to complete the tour cost.
    • Repeats the process from alternative starting vertices to seek a smaller tour.
    • Recognises the resulting tour as an upper bound rather than a guaranteed optimum.

    Common mistakes and how to put them right

    • Omits the final edge back to the start.

      Put it right: Add the closing edge to complete the tour and its cost.

    • Revisits an already visited vertex mid-tour.

      Put it right: Only move to unvisited vertices until all are covered.

    • Treats the single nearest neighbour tour as optimal.

      Put it right: Compare runs from several starts to find a better upper bound.

    Exam tips

    • Lay out a table of visited vertices and running totals so each choice is traceable.
    • State the starting vertex explicitly and show every edge weight you add.
    • Run from more than one start when asked for the best upper bound.

    Try the lesson

    The start of the Algorithms on graphs II - Paper 3D: Decision Mathematics 1: 3.2 The nearest neighbour algorithm. lesson, made from teaching notes for this specification point.

    Have a go first

    A nearest neighbour algorithm is applied to a complete graph of five vertices. Starting at vertex A, the algorithm selects the cheapest unused edge from the current vertex at each stage. It has just arrived at vertex E, and the only unvisited vertex is D. Which vertex must the algorithm visit next?

    There is more to this lesson

    The full lesson goes on to check your understanding and help you earn the marks. Create a free account to carry on, with your progress saved.

    Carry on with the full lesson

    5 free practice questions every day · Free forever · No card required

    Test your understanding of Algorithms on graphs II - Paper 3D: Decision Mathematics 1: 3.2 The nearest neighbour algorithm.

    Active recall beats re-reading. Take an instant quiz now to test what you’ve learned and lock it into long-term memory.

    Take topic quiz

    5 free practice questions every day · Free forever · No card required