IT 취미생활.  
Front Page
Tag | Location | Media | Guestbook | Admin   
 
'It'에 해당하는 글(34)
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
C 1seg 미라지폰 영어 이메일 MP3 퇴사 C++ DVB 서태지 티스토리 초대장 English 음식 출장 Linux Brazil DVB-T ISDB-T warning 개발자 알고리즘 DirectShow Dshow project Java english email 벨소리 변경 군대 Debug Algorithm M480 티스토리초대 Wince5.0 Windows Mobile6.0 VC++ It Error Case spam mail isdbt debugging
 Calendar
«   2024/05   »
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 31
 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