
Adu-Poku D.
asked 11/20/17Simple pseudo code
1 Expert Answer

Patrick B. answered 06/04/19
Math and computer tutor/teacher
#include <stdio.h>
insertionSort( int * A, int N)
{
int key;
int iLoop,jLoop;
for (iLoop = 1; iLoop < N; iLoop++)
{
key = A[iLoop];
jLoop = iLoop-1;
/* Moves elements of A[0..i-1], that are
greater than key, to one position ahead
of their current position */
while ((jLoop >= 0) && (A[jLoop]>key))
{
A[jLoop+1] = A[jLoop];
jLoop = jLoop-1;
}
A[jLoop+1] = key;
}
}
int main()
{
int A[10]={ 12,84,46,32,59,77,24,33,65,5};
insertionSort(A,10);
for (int iLoop=0; iLoop<10; iLoop++) { printf(" %d \n",A[iLoop]); }
}
Still looking for help? Get the right answer, fast.
Get a free answer to a quick problem.
Most questions answered within 4 hours.
OR
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.
Kenneth S.
11/20/17