Insertion Sort

C++:
01 void InsertSort(int array[], int N)
02 {
03     for(int i=1;i<N;i++)
04     {
05         int k=array[i];
06         int j=i1;
07         for(;j>=0;j)
08         {
09             if(array[j]>k)
10             {
11                 array[j+1]=array[j];
12             }
13             else
14             {
15                 break;
16             }
17         }
18         array[j+1]=k;
19     }
20 }
Advertisements
This entry was posted in Array and linked list. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s