1 / 10

양승혁 Yang_ka@kunsan.ac.kr 군산대학교 통계컴퓨터과학과 정보과학기술 연구실 2012.09.4

알 고 리 즘. Chap 5.3 레드블랙트리. 양승혁 Yang_ka@kunsan.ac.kr 군산대학교 통계컴퓨터과학과 정보과학기술 연구실 2012.09.4. 목차. 레드블랙 트리 특성 삽입 삭제 성능 분석. 레드블랙 트리. NIL. NIL. NIL. NIL. NIL. 레드블랙트리 예. NIL. 실제 구현시의 NIL 노드. NIL. NIL. NIL. NIL. 레드블랙 트리 균형잡힌 이진검색 트리에서 모든 노드에 레드 또는 검정 색상 특성 루트는 블랙

Download Presentation

양승혁 Yang_ka@kunsan.ac.kr 군산대학교 통계컴퓨터과학과 정보과학기술 연구실 2012.09.4

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 알 고 리 즘 Chap 5.3 레드블랙트리 양승혁 Yang_ka@kunsan.ac.kr 군산대학교 통계컴퓨터과학과 정보과학기술 연구실 2012.09.4

  2. 목차 • 레드블랙 트리 • 특성 • 삽입 • 삭제 • 성능 분석 IST (Information Sciences & Technology) Laboratory

  3. 레드블랙 트리 NIL NIL NIL NIL NIL 레드블랙트리 예 NIL 실제 구현시의 NIL노드 NIL NIL NIL NIL • 레드블랙 트리 • 균형잡힌 이진검색 트리에서 모든 노드에레드 또는 검정 색상 • 특성 • 루트는 블랙 • 모든 리프(NIL)는 블랙 • 노드가레드이면 그 노드의 자식은 반드시 블랙 • 루트 노드에서 임의의 리프노드에 이르는 경로에서 만나는 블랙노드의 수는 모두 같다 IST (Information Sciences & Technology) Laboratory

  4. 레드블랙트리의 삽입 • 삽입 • 이진검색트리에서의삽입후레드로 색칠 IST (Information Sciences & Technology) Laboratory

  5. 버블정렬(1/2) • 버블정렬 알고리즘 • bubbleSort(A[],n) • { • for last ← n downto 2 • for I ← 1 to last -1 • if(A[i] > A[i+1] then A[i] ↔ A[i+1]; • } • 수행시간 • 버블정렬 • 두 인접한 원소를 검사하여 정렬 IST (Information Sciences & Technology) Laboratory

  6. 버블정렬(2/2) • 버블정렬 알고리즘 • bubbleSort(A[],n) • { • for last ← n downto 2 { • sorted ← TRUE; • for I ← 1 to last -1 { • if(A[i] > A[i+1] then A[i] ↔ A[i+1]; • sorted ← FALSE; • } • } • if(sorted=TRUE) then return; • } • } • 수행시간 • Θ(n) • 버블정렬 IST (Information Sciences & Technology) Laboratory

  7. 삽입정렬(1/3) • 삽입정렬 알고리즘 • insertionSort(A[],n) • { • for i← 2 to n • A[1...i]의 적당한 자리에 A[i]를 삽입 • } insertionSort(A[],n) { for i← 2 to n { loc ← i-1; newItem← A[i]; //이 지점에서 A[1...i-1]은 이미 정렬되있는 상태 while(loc ≤1 and newItem < A[loc] { A[loc+1] ← A[loc]; loc--; } A[loc+1] ← newItem; } } • 삽입정렬 • 모든 요소를 앞에서부터 차례대로 이미 정렬된 배열 부분과 비교하여 자신의 위치를 찾아 삽입하는 정렬 IST (Information Sciences & Technology) Laboratory

  8. 삽입정렬(2/3) 삽입정렬 동작 예 IST (Information Sciences & Technology) Laboratory

  9. 삽입정렬(3/3) • 삽입정렬 수행시간 • O(n2) • Worst case • O(n2) = 1+2+···+(n-2)+(n-1) • Average case • O(n) = ½ (1+2+···+(n-2)+(n-1)) IST (Information Sciences & Technology) Laboratory

  10. 감사합니다 Yang_ka@kunsan.ac.kr 군산대학교 정보통계학과 정보과학기술 연구실 2012.01.03 양승혁 Yang_ka@kunsan.ac.kr 군산대학교 통계컴퓨터과학과 정보과학기술 연구실 2012.09.4

More Related