728x90
300x250

[자료구조(Data Structure)] - 2. Insertion Sort

 

[슈도코드]
 

void insertsort(int *arr, int n)

{

int i = 1;

int j ;

int temp ;

 

while ( i < n )

{

temp = arr[i] ;

j = i - 1;

 

while ( j >= 0 && ( temp < pArr[ j ] ) )

{

pArr [ j + 1 ] = pArr[ j ] ;

j-- ;

}

pArr [ j + 1 ] = temp ;

 

}

}

 

 

반응형

+ Recent posts