private void heapify(int i) {
		if (i <= 0 || i >= length) {
			return;
		}
		
		System.out.println("heapify " + i);
		int left = 2*i;
		int right = 2*i + 1;
		
		if (right < length) {
			//left is smaller
			if (heap[left].compareTo(heap[right]) < 0) {
				if (heap[i].compareTo(heap[left]) > 0) {
					switchTwo(i, left);
					heapify(left);
				}
			}
			//right is smaller
			else {
				if (heap[i].compareTo(heap[right]) > 0) {
					switchTwo(i, right);
					heapify(right);
				}
			}
		}
		else if (left < length) {
			if (heap[i].compareTo(heap[left]) > 0) {
				switchTwo(i, left);
				heapify(i/2);
			}
		}
	}