Skip to content

Latest commit

 

History

History
18 lines (17 loc) · 238 Bytes

heap_logic.md

File metadata and controls

18 lines (17 loc) · 238 Bytes
insertHeap(A, n, value){
    n=n+1;
    A[n] = value;
    i = n;
    
while (i>1){
    parent = floor(i/2);
    if(A[parent] < A[i]){
        swap(A[parent], A[i]);
        i = parent;
    }
    else{
        return;
    }
}
}