```
public class Ex1 {
public static int maximumX (Point [] vertices)
{
int max = maxX (vertices, 0, vertices.length-1);
back max;
}
private static int maxX (Point [] vertices, left int, right int)
{
int mid = (left + right) / 2;
if (vertices.length == 3)
if (summits[1].getX ()> vertices[2].getX ())
returns 1;
other
returns 2;
if (summits[mid].getX ()> vertices[mid-1].getX () && summits[mid].getX ()> vertices[mid+1].getX ())
{
return to the middle;
}
if (summits[mid].getX ()> vertices[mid-1].getX () && summits[mid].getX () <vertices[mid+1].getX ())
{
returns maxX (vertices, middle, right);
}
if (summits[mid].getX () summits[mid+1].getX ())
{
returns maxX (vertices, left, middle);
}
return -1;
}
public static int maximumY (Point [] vertices)
{
int max = maxY (vertices, 0, vertices.length-1);
back max;
}
public static int maxY (Point [] vertices, left int, right int)
{
int mid = (left + right) / 2;
if (vertices.length == 3)
{
if (summits[0].getY ()> vertices[1].getY () && vertices[0].getY ()> vertices[2].getY ())
returns 0;
if not (vertices[1].getY ()> vertices[2].getY ())
returns 1;
other
returns 2;
}
if (summits[mid].getY ()> vertices[mid-1].getY () && vertices[mid].getY ()> vertices[mid+1].getY ())
{
return to the middle;
}
if (summits[mid].getY ()> vertices[mid-1].getY () && vertices[mid].getY () <vertices[mid+1].getY ())
{
returns maxY (vertices, middle, right);
}
if (summits[mid].getY () summits[mid+1].getY ())
{
returns maxY (vertices, left, middle);
}
return -1;
}
public static void main (String[] args) {
Point[] vertices = {
new point (-2, 6), new point (0, 10), new point (6, 14)
, new point (12, 12), new point (14, 6),
new point (10, 2), new point (4, 0)};
System.out.println (maximumX (vertices));
Point[] vertices2 = {
new point (0, 0), new point (1, 1), new point (2, 0)
};
System.out.println (maximumX (vertices2));
System.out.println (maximumY (vertices));
System.out.println (maximumY (vertices2));
}
```

}

As you can see, I have created an algorithm that looks for the maximum values of X and Y and returns the index.

I'm not sure how to determine what O (logn) is, but I followed the logic of the binary search and if it will work in any polygon given convex, the first element of the array has the smallest X coordinate.

Would like help to execute the code on difficult polygons and also understand how can I benefit (assuming it is) O (logn).

Please advice!