insert(x){ int c = ++currentSize; while(c!=1 && x>heap[c/2]){ //get its parent node and compare heap[c] = heap[c/2]; //move down parent ____________________________________________________________
// move parent down because it smaller c/=2; //move up a level } heap[c] = x; //the right position of insert. //at this time heap[c] has been moved away by previous //statement heap[c] = heap[c/2] } ____________________________________________________________
//c is used to control level, c/=2 move up level ____________________________________________________________
//heap[c/2] get its parent