privatebooleanverifyPostorder(int[] postorder, int i, int j) { if (i >= j) { returntrue; }
introot= postorder[j]; for (intk= i; k < j; k++) { // find right tree startIndex if (postorder[k] > root) { for (intl= k + 1; l < j; l++) { if (postorder[l] < root) { returnfalse; } } return verifyPostorder(postorder, i, k - 1) && verifyPostorder(postorder, k, j - 1); } }