Skip to Content
똑똑한 코드 작성을 위한 실전 알고리즘
book

똑똑한 코드 작성을 위한 실전 알고리즘

by 조지 하이네만, 윤대석
May 2022
Beginner to intermediate
296 pages
5h 54m
Korean
Hanbit Media, Inc.
Content preview from 똑똑한 코드 작성을 위한 실전 알고리즘
181
5
정렬
이 장에서 배운 내용은 다음과 같다.
성능이
O
(
N
2
)인 일부 기본 정렬 알고리즘은 대규모 데이터 세트를 정렬하는 데 부적합하다.
재귀 개념은 문제를 더 작은 하위 문제로 나누어 해결하는 핵심 전략이다.
병합 정렬과 힙 정렬은 서로 다른 방식으로
O
(
N
log
N
) 성능을 달성한다.
퀵 정렬은 병합 정렬에 필요한 추가 저장 공간 없이도
O
(
N
log
N
) 성능을 달성한다.
팀 정렬은 파이썬에서 사용하는 기본 정렬 알고리즘으로, 다른 프로그래밍 언어에서도 점차 도입하고
있다.
5.12
연습 문제
1.
A
에서 값
t
가 나타나는 횟수를 반환하는 재귀 함수
count
(
A
,
t
)
를 작성하자.
find
_
max
(
A
)
와 비슷한 재귀적 구조로 구현해야 한다.
2.
0
에서
N
-
1
까지 고유한 정수
N
개의 순열을 포함하는 배열이 주어졌을 때 값을 오름차순으
로 정렬하는 데 필요한 최소 교환 횟수를 구하자. 그리고 이러한 배열을 입력으로 받아 정
숫값을 반환하는
num
_
swaps
(
A
)
함수를 작성하자. 배열을 실제로 정렬할 필요는 없고 정렬
에 필요한 교환 횟수만 구하면 된다.
고유한 값
N
개를 가지는 배열로 동작하는 문제를
3
장의 심볼 테이블을 사용해 확장하고,
[그림
5
-
1
]에
5
회의 교환이 필요함을 확인해보자.
3.
값이
N
개인 정렬되지 않은 배열에서 가장 큰 값을 찾는 재귀 함수인
find
_
max
(
A
)
에서 필
요한 총 비교 횟수는 얼마인가? 이 횟수는
1
장에서 본
largest
(
A
)
를 사용해 비교한 횟수
와 비교해 더 작은지 (혹은 ...
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.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’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
QuotationMarkI 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
QuotationMarkI’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
QuotationMarkI'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.
Mark W.
Embedded Software Engineer

You might also like

데이터 익명화를 위한 파이프라인

데이터 익명화를 위한 파이프라인

루크 아버클, 칼리드 엘 에맘
개발 7년차, 매니저 1일차

개발 7년차, 매니저 1일차

권원상, 한민주, 카미유 푸르니에

Publisher Resources

ISBN: 9791162245644