2.1-2 Rewrite the INSERTION-SORT procedure to sort into non increasing instead of nondecreasing order.
INSERTION-SORT
1: for j = 2 to A.length
2: key=A[j]
3: i = j -1
4: while( i > 0 && A[i] < key )
5: A[i+1]=A[i]
6: i=i-1
7: A[i+1]=key;
No comments:
Post a Comment