direct insertion sort
direct insertion sort
Straight Insertion Sort (Straight Insertion Sort) is the simplest sorting method. The basic operation is to directly insert a record into an already sorted ordered sequence list, thereby obtaining a new sorted sequence with the number of records increased by 1. surface.
Algorithm ideas
For example, when playing cards, the order of the cards dealt to the hand is as follows, and the insertion method is used for sorting.
Simulate hand calculation
Algorithm implementation
- Implemented without sentinels
void InsertSort(int A[],int n){
int i,j,temp;
for ( i = 1; i < n