Q:

# What is the nearest neighbor algorithm?

A:

The nearest neighbor algorithm is one of the initial approximate algorithms used in finding a possible solution to the travelling salesman problem. Though it shortens the tour, it is a sub-optimal solution.

## Keep Learning

Credit: ZenShui/Eric Audras PhotoAlto Agency RF Collections Getty Images

There are several steps to follow when applying the nearest neighbour algorithm to the problem. First, one has to choose an arbitrary vertex as the current vertex. Then, the shortest edge that connects an unvisited node to the current vertex should be determined. This unvisited point should then be set as the current vertex and marked as visited. If, after this, all the vertices in selected domain are visited, one should terminate the process. If not, then one should execute the second step again. Practical areas where this algorithm has been successfully used include coding satellite images, analysing handwritten digits and solving regression problems.

Sources:

## Related Questions

• A:

A simple solution to a Rubik's cube is the algorithm R' D' R F' D' R R’ D D R D R’ D’ R F R U R’ U’ F’ R U R’ U R U U R’ U U R U’ L’ U R’ U’ L R’ D’ R D. The algorithm uses the key: F for front, R for right, U for up, B for back, L for left and D for down. Apostrophes mark counter-clockwise rotations.

Filed Under:
• A:

An individual can resolve a tree dispute with a neighbor by talking to the neighbor about the tree issue, and if the neighbor does not do anything to resolve the problem, the individual may have the option to take him to court, FindLaw says. The tree may be considered a nuisance by law, and, therefore, an individual could initiate a nuisance claim with the court.

Filed Under:
• A:

Deal with a neighbor's barking dog by making the neighbor aware of the situation, asking him to resolve the problem, and then following up with the proper authorities if the problem isn't resolved. Landlords, property managers and the police are all resources to use if the problem can't be resolved amicably between the neighbors.