void paint(Graphics g, int x, int y, int w, int h)
, or void paint(Graphics g, Rectangle r)
if (!empty) // avoid infinite recursion draw the root in the middle, near the top left.paint(g, the rectangle which is the left half of the remainder of r, below the root) right.paint(g, the rectangle which is the right half of the remainder of r, below the root)Like this:
Rectangle getBounds()
Insets getInsets()
class BinaryTree<T> { T root; BinaryTree<T> right, left; BinaryTree() { }
int ht(), int countRoots(), int countLeaves(), countInteriorNodes(), traverse()
(preorder/inorder
/postorder)insert new element at the insertion point (first empty slot, to the right of the step on the near-delta) swap up to it's proper place (to preserve heapness) i.e. if ! at root of heap if it is < its parent (i.e. is out of place) { swap roots with parent recurse on parent }running time?
save the root (to return) swap from rightmost, bottom row (to the left of the step on the near-delta) and trim the old root swap the root down to the proper place i.e. if ! a leaf if it is > either child (or just the left, if there's no right) { swap roots with smaller child recurse on that child }running time?
for each element in the list insert in the heap list.clear(); while !heap.isEmpty() list.add(heap.deleteRoot());