Can anybody tell me what's going on with the following code:
int compareX(const void* a, const void* b)
{
Point *p1 = (Point *)a, *p2 = (Point *)b;
return (p1->x - p2->x);
}
I have taken this code from geeks for geeks, the closest pair of points. can anyone explain to me the similar code in a much simpler and easy way with line by line explanation
also, I am unable to understand this piece of code as well:
float bruteForce(Point P[], int n)
{
float min = FLT_MAX;
for (int i = 0; i < n; ++i)
for (int j = i+1; j < n; ++j)
if (dist(P[i], P[j]) < min)
min = dist(P[i], P[j]);
return min;
}
What's the use of FLT_MAX
here?