Library sort: Difference between revisions

Content deleted Content added
Tags: Mobile edit Mobile web edit
Line 51:
===Pseudocode===
 
'''procprocedure''' rebalance(A, begin, end) '''is'''
r ← end
w ← end * 2
'''while''' r >= begin '''do'''
A[w+1] ← gap
A[w] ← A[r]
Line 60:
w ← w - 2
 
'''procprocedure''' sort(A) '''is'''
n ← length(A)
S ← new array of n gaps
'''for''' i ← 1 to floor(log2(n) + 1) '''do'''
'''for''' j ← 2^i to 2^(i+1) '''do'''
ins ← binarysearch(A[j], S, 2^(i-1))
insert A[j] at S[ins]