Skip to content

Instantly share code, notes, and snippets.

@Sable-Shinigami
Sable-Shinigami / Tour.java
Last active May 10, 2022 10:21
Travelling Salesman Assignment for Algorithms class
/*
* This is my code for a Travelling Salesman Problem assignment from college.
* I was supposed to create a Hamilton Cycle of N points on a 2D plane i.e. find the shortest
* path that visits all points exactly once and returns to the starting point.
* I implemented both the Smallest Insertion and Nearest Insertion algorithms which inserts
* a point where it will create the smallest increase in the total length of the cycle and
* insert a point where it is nearest to an other point already on the cycle respectively.
*
* In our brief we were informed that speed was the most important factor and so I decided
* to try and squeeze every last nanosecond out of the program... even at the cost of the memory.