Skip to main content
. 2021 Mar 12;21(6):2024. doi: 10.3390/s21062024
Algorithm 5 INSERT procedure for min-heap EHS [13]
  • Input:

    EL(UL),ER(UR), auxiliary data

  • Output:

    None

  • 1:

    idx(sizeof(EHS))+1 {Insert the new item as the last leaf node}

  • 2:

    EHS[idx].ELEL(UL)

  • 3:

    EHS[idx].ERER(UR)

  • 4:

    EHS[idx].auxauxiliarydata

  • 5:

    whileidx>1do {Perform upheap to restore the heap order}

  • 6:

    if COMP(EHS[idx].EL,EHS[idx/2].ER)=1 then

  • 7:

    swap EHS[idx] and EHS[idx/2]

  • 8:

    idxidx/2

  • 9:

    else

  • 10:

      break

  • 11:

    end if

  • 12:

    end while