는 값들을 음영 처리하고, 최종 위치에 놓인 값은 굵은 테두리로 표시했다. 굵은 테두리 안의
값은 더는 교환되지 않으며 외부의 값들은 아직 정렬되지 않았다.
가장 큰 값
24
를 찾기 위해 남은 값들을 조사하고(
6
회 비교)
A
[
5
]
와
A
[
7
]
을 교환해 가장 큰
값을 배열의 맨 마지막으로 이동시켰다. 남은 값 중에 가장 작은 값
5
를 찾았고(
5
회 비교)
A
[
1
]
과
A
[
6
]
을 교환해
5
를 알맞은 위치로 이동시켰다.
21
이 알맞은 위치에 있음을 검증하기
위해
4
회 비교했으며, 이 시점에 교환은 일어나지 않았다.
3
회 비교 후 남은 값 중에
15
가 제일 작았고, 두 번째
15
를 선택해
A
[
4
]
와
A
[
2
]
를 교환했다.
2
회 비교로
15
는 인덱스 위치
3
임을 검증했으므로, 추가
1
회 비교로
A
[
4
]
와
A
[
5
]
를 교환해
19
를 알맞은 위치로 이동시켰다. [그림
5
-
1
]에 그려진 마지막 단계에서 값
20
왼쪽에 있는 값은
모두
20
보다 작거나 같고,
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.
O’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
I wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
I’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
I'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.