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

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

by 조지 하이네만, 윤대석
May 2022
Beginner to intermediate
296 pages
5h 54m
Korean
Hanbit Media, Inc.
Content preview from 똑똑한 코드 작성을 위한 실전 알고리즘
145
4
dequeue
()
로직이 맞다는 확신을 얻으려면 엔트리를 한 개만 포함하는 힙에서 해당 로직이 동
작하는 방식을 살펴보자. 엔트리가 한 개인 힙에서
dequeue
()
를 하면
max
_
entry
의 값을 반
환받을 것이고
sink
()
를 호출하기 전에
N
0
이 되므로,
sink
()
while
루프의 조건에서
2
×
1
>
0
이 되어 아무것도 하지 않을 것이다.
4.6
요약
이진 힙 구조는 우선순위 큐 추상 데이터 타입의 효율적인 구현을 제공한다.
7
장에서 논의할
여러 알고리즘은 우선순위 큐에 의존한다.
(값, 우선순위 ) 엔트리의
enqueue()
수행은 성능이
O
(
log
N
)이다.
우선순위가 가장 높은 엔트리의
dequeue()
수행은 성능이
O
(
log
N
)이다.
힙의 총 엔트리 수를 얻는 성능은
O
(
1
)이다.
이번 장에서는 최대 이진 힙에 대해서만 학습했다.
최소 이진 힙
min
binary
heap
을 실현하려면 더
작은 우선순위 값을 가지는 엔트리가 더 높은 우선순위를 가지도록 약간만 변경하면 된다. 이
7
장과 연관이 있다. [코드
4
-
2
]에서 미만(
<
) 대신에 초과(
>
)를 사용해
less
()
메서드를
재작성하면 된다. 이외의 코드는 모두 동일하다.
def less(self, i, j):
return self.storage[i].priority ...
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