**Shortest Path among co-ordinates**↵
==================================== ↵
↵
Given (N+1) points. All the N points lie on x- axis. Remaining one point (HEAD point) lies anywhere in the coordinate plane. Given a START point on x- axis.↵
↵
Find the shortest distance to cover all the points starting from START point.We can traverse a point multiple times.↵
↵
Example -↵
↵
N+1=4↵
↵
points on x axis↵
(0,0),(1,0),(2,0)↵
↵
HEAD Point↵
(1,1) // only head point can lie anywhere ,rest all will lie on x axis↵
↵
START Point↵
(1,0)↵
↵
Shortest path -↵
↵
(1,0) → (2,0) → (1,1) → (0,0)↵
Length of path → 1 + 1.414 + 1.414.↵
↵
Pls help me with the logic / code
↵
Given (N+1) points. All the N points lie on x- axis. Remaining one point (HEAD point) lies anywhere in the coordinate plane. Given a START point on x- axis.↵
↵
Find the shortest distance to cover all the points starting from START point.We can traverse a point multiple times.↵
↵
Example -↵
↵
N+1=4↵
↵
points on x axis↵
(0,0),(1,0),(2,0)↵
↵
HEAD Point↵
(1,1) // only head point can lie anywhere ,rest all will lie on x axis↵
↵
START Point↵
(1,0)↵
↵
Shortest path -↵
↵
(1,0) → (2,0) → (1,1) → (0,0)↵
Length of path → 1 + 1.414 + 1.414.↵
↵
Pls help me with the logic / code