ScratchData LogoScratchData
Back to kriblo_test's profile

Travelling Salesman using brute force & Heap's algorithm

KRkriblo_test•Created October 19, 2023
Travelling Salesman using brute force & Heap's algorithm
5
3
88 views
View on Scratch

Instructions

Click the green flag to randomize. A travelling salesman needs to travel to (in this project) six cities (starting city is the green dot). What is the shortest route? In this project I: - Randomize the position of the cities - Use Heap's non-recursive algorithm to generate all possible permutations of the cities (not the starting city) - Calculate the travelling distance for each permutation - Save the shortest distance and it's permutation - Draw the shortest route, to illustrate All code by me (@kriblo). Thank you @RokCoder, for the inspiration to make this project. This is my simple, brute force and non-optimized solution to the Travelling salesman problem: https://en.wikipedia.org/wiki/Travelling_salesman_problem See also, Heap's algorithm: https://en.wikipedia.org/wiki/Heap%27s_algorithm Check out @PutneyCat's solution: https://scratch.mit.edu/projects/131906576/

Project Details

Project ID910720431
CreatedOctober 19, 2023
Last ModifiedOctober 20, 2023
SharedOctober 20, 2023
Visibilityvisible
CommentsAllowed