(int x)
| 30 | } |
| 31 | |
| 32 | public void insert(int x) { |
| 33 | // double size of array if necessary |
| 34 | if (n == pq.length - 1) resize(2 * pq.length); |
| 35 | |
| 36 | // add x, and percolate it up to maintain heap invariant |
| 37 | pq[++n] = x; |
| 38 | swim(n); |
| 39 | } |
| 40 | |
| 41 | public int delMax() { |
| 42 | if (isEmpty()) |