import java.util.Arrays;
public class Triedenia {
public static boolean jeHaldou(int[] pole) {
for (int i = 1; i < pole.length; i++) {
int idxRodica = (i - 1) / 2;
if (pole[idxRodica] < pole[i])
return false;
}
return true;
}
public static int[] zluc(int[] p1, int[] p2) {
int[] vysledok = new int[p1.length + p2.length];
int idx1 = 0;
int idx2 = 0;
int vIdx = 0; // = idx1+idx2
while ((idx1 < p1.length) && (idx2 < p2.length)) {
if (p1[idx1] < p2[idx2]) {
vysledok[vIdx] = p1[idx1];
idx1++;
vIdx++;
} else {
vysledok[vIdx] = p2[idx2];
idx2++;
vIdx++;
}
}
if (p1.length == idx1) {
System.arraycopy(p2, idx2, vysledok, vIdx, vysledok.length - vIdx);
} else {
System.arraycopy(p1, idx1, vysledok, vIdx, vysledok.length - vIdx);
}
return vysledok;
}
public static void main(String[] args) {
int[] p1 = {8,10,15,16,30};
int[] p2 = {2,7,9,15};
System.out.println(Arrays.toString(zluc(p1, p2)));
}
}