import java.util.Arrays;
public class Cvicenie {
public static boolean jeUsporiadane(int[] p) {
for (int i = 0; i < p.length - 1; i++) {
if (p[i] > p[i + 1])
return false;
}
return true;
}
public static int binarneHladajIndex(int[] p, int hodnota) {
int odIdx = 0;
int poIdx = p.length - 1;
while (odIdx <= poIdx) {
int stred = (odIdx + poIdx) / 2;
if (p[stred] == hodnota)
return stred;
if (hodnota < p[stred]) {
// odIdx = odIdx;
poIdx = stred - 1;
} else {
odIdx = stred + 1;
// poIdx = poIdx;
}
}
return -1;
}
public static void main(String[] args) {
int[] p = new int[] { 12, 22, 13, 4, 52, 36, 77, 8 };
System.out.println(Arrays.toString(p));
TriediaciAlgoritmus triedic = new BubbleSort();
triedic.utried(p);
System.out.println(Arrays.toString(p));
//System.out.println(jeUsporiadane(p));
//System.out.println(binarneHladajIndex(p, 5));
}
}