(int num)
| 155 | } |
| 156 | |
| 157 | public static int pre(int num) { |
| 158 | int i = head, last = head; |
| 159 | int ans = Integer.MIN_VALUE; |
| 160 | while (i != 0) { |
| 161 | last = i; |
| 162 | if (key[i] >= num) { |
| 163 | i = left[i]; |
| 164 | } else { |
| 165 | ans = Math.max(ans, key[i]); |
| 166 | i = right[i]; |
| 167 | } |
| 168 | } |
| 169 | splay(last, 0); |
| 170 | return ans; |
| 171 | } |
| 172 | |
| 173 | public static int post(int num) { |
| 174 | int i = head, last = head; |