트리를 사용해 구현된 우선순위 큐의 런타임 성능을 비교해보는 것은 자연스러운 일이다. 해당
이진 탐색 트리는
priority
를 이용해 구조를 탐색한다(그림
6
-
15
).
그림
6-15
이진 트리를 우선순위 큐로 사용하기(우선순위는 숫자이고 값은 요소 심볼이다)
이진 탐색 트리로 우선순위 큐를 구현하면 두 가지 장점이 있다.
●
배열 기반 힙은 개수가 고정된 값을 위한 저장 공간을 미리 생성해야 한다. 반면에 이진 탐색 트리를 사
용하면 구조가 필요한 만큼 커질 수 있다.
219
6
장
이진 트리
●
힙 구조에서는 값을 꺼내지 않고 우선순위대로 우선순위 큐를 순회
6
할 수 있는 반복자를 제공할 방법이
없다. 반면에 이진 탐색 트리
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.