Skip to main content
. 2021 Nov 27;23(12):1592. doi: 10.3390/e23121592
Algorithm A2: Correct two consecutive insertion symbols
  • Input: 

    n,a,y,0xjn+2.

  • Output: 

    c=(c1,c2,,cn)C(n,4).

  •  1:

    Calculate Δ and h1+h2 as in Table 3.

  •  2:

    Set j=1.

  •  3:

    if  Δ2r  then

  •  4:

       while jn+1 do

  •  5:

         if mod(Δ,2)=1 then

  •  6:

            if 2k0xjn+2(j1)+2(nj)+5=Δ then

  •  7:

              xj=x¯j1; xj+1=xj1

  •  8:

              c=ins2_correct2(j,n,a,y,h1+h2)

  •  9:

            else

  •  10:

              jj+1

  •  11:

            end if

  •  12:

         else

  •  13:

            if 2k0xjn+2(j1)+2(nj)+4=Δ then

  •  14:

              xj=x¯j1; xj+1=x¯j1

  •  15:

              c=ins2_correct2(j,n,a,y,h1+h2)

  •  16:

            else

  •  17:

              jj+1

  •  18:

            end if

  •  19:

         end if

  •  20:

       end while

  •  21:

    else

  •  22:

       while jn+1 do

  •  23:

         if mod(Δ,2)=1 then

  •  24:

            if 2k0xjn+2(j1)+1=Δ then

  •  25:

              xj=xj1; xj+1=x¯j1

  •  26:

              c=ins2_correct2(j,n,a,y,h1+h2)

  •  27:

            else

  •  28:

              jj+1

  •  29:

            end if

  •  30:

         else

  •  31:

            if 2k0xjn+2(j1)=Δ then

  •  32:

              xj=xj1; xj+1=xj1

  •  33:

              c=ins2_correct2(j,n,a,y,h1+h2)

  •  34:

            else

  •  35:

              jj+1

  •  36:

            end if

  •  37:

         end if

  •  38:

       end while

  •  39:

    end if