Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

how to implement pesudocode from use-me sort algorithm in java?

i have tried to implement pseudocode of use-me sort algorithm in java, but it doesn't works, anyone can explain or show me how to implement this pseudocode correctly. i have tried but i got array index out of bound. This algorithm will work by dividing the array that has been sorted by the one that hasn't, this portion of the array that hasn't been sorted is called the UM array, then the array will merge recursively one by one using binary search to find the right position until all the elements are sorted

UM array image

    USE-ME(A)
1  i←0
2   while i < N-1
3       if A[i] > A[i+1]
4           then k←i+1
5           while A[k] > A[k+1] and k < N-1
6               do k++
7           if k ≠ i+1
8               then m ← k-i-1
9               DESC(A, i, k, m)
10              i ← k
11          else
12              while A[k]≤A[k+1] and k<N-1 and A[k+1]<A[i]
13                  do k++
14              m ← k-i-1
15              ASC(A, i, k, m)
16              i ← k
17      else
18          i++

sorce: https://www.ijais.org/archives/volume7/number8/675-1228

full pseudocode: http://collabedit.com/qpb6m

my java code : http://collabedit.com/hfhsh

Comments