I wanted to find shortest time algorithm for finding the diameter of a convex hull, so I found Shamos algorithm on wikipedia:
GetAllAntiPodalPairs(p[1..n])
i0 = n
i = 1
j = i + 1
while (Area(i, i + 1, j + 1) > Area(i, i + 1, j))
j = j + 1
j0 = j
while (j != i0)
i = i + 1
yield i, j
while (Area(i, i + 1, j + 1) > Area(i, i + 1, j)
j = j + 1
if ((i, j) != (j0, i0))
yield i, j
else
return
if (Area(j, i + 1, j + 1) = Area(i, i + 1, j))
if ((i, j) != (j0, i0))
yield i, j + 1
else
yield i + 1, j
And this is a gif to visualize the algorithm:
I cannot understand the Area in the code . how it will be calculated given i , i+1 and j+1? And what's exactly the p[1..n] ? Is it the given points or that's different?
I've created a shape for solving that using this algorithm. I know that's not easy but can someone trace the algorithm for this shape? Anybody like me will enjoy it:

