IT 취미생활.  
Front Page
Tag | Location | Media | Guestbook | Admin   
 
'삽입 정렬'에 해당하는 글(1)
2008.10.18   [알고리즘] Insertion Sort(삽입정렬)


[알고리즘] Insertion Sort(삽입정렬)
간단하게 작성한 삽입 정렬입니다.


간단하게 원리를 설명드리면, 배열에 index는 1에서 부터 시작해서(1 <= x < N ) N까지
정렬을 합니다.  index한 녀석을 집어 넣을 위치를 찾는 것입니다.

코드는 따로 설명 드리지 않겠습니다.

void InsertSort( int *_arrayBuffer, int _bufferSize )
{
  for( int i = 1; i < _bufferSize; i++ )
  {
    int insertionValue= _arrayBuffer[ i ];
    int nInsertPosition = i;
    while( _arrayBuffer[nInsertPosition-1] > insertionValue && nInsertPosition > 0 )
    {
      _arrayBuffer[nInsertPosition ] = _arrayBuffer[ nInsertPosition - 1 ];
      nInsertPosition--;
    }
    _arrayBuffer[ nInsertPosition ] = insertionValue;
  }
}

배열안에 값들이 정렬이 이루어져 있으면 N 에 대한 성능을 가질 수 있다고 하는군요.

그럼 고운하루 되세요.



BLOG main image
취미생활
 Notice
 Category
분류 전체보기 (191)
매일매일갱생 (83)
서버개발 (1)
임베디드개발 (12)
Programming (80)
Personal Projects (6)
유용한 프로그램 (0)
 TAGS
영어 이메일 출장 Windows Mobile6.0 isdbt 퇴사 DirectShow english email Debug spam mail Algorithm C 군대 warning Dshow English debugging 티스토리초대 DVB 음식 Linux VC++ It DVB-T 알고리즘 Java MP3 Brazil M480 1seg 미라지폰 서태지 티스토리 초대장 ISDB-T project 벨소리 변경 Wince5.0 개발자 Error Case C++
 Calendar
«   2025/04   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
 Recent Entries
 Recent Comments
 Recent Trackbacks
 Archive
 Link Site
zextor
괴짜 프로그래머의 일상사~@@
Gag & Peace, and more..
Kazakhstan Almaty.......
Min-A
Sadgarret
Steve Yoon's log
가슴 뛰는 삶을 살아라
오스틴 파워
GUI sin
melanie parker_Lady
제레미의 TV 2.0 이야기..
 Visitor Statistics
Total :
Today :
Yesterday :
rss