Code&Data Insights
[Data Structure] Priority Queue | 우선순위 큐 본문
[Data Structure] Priority Queue | 우선순위 큐
paka_corn 2022. 11. 13. 10:54< Priority Queue >
- an ADT for storing a collection of prioritized elements; the elements are referred to as values.
(ADT - Abstract Data Type,
this focuses on the behaviour of a data structure rather than on any implementation detail
데이터 구조를 사용해 코드를 구현하는 것보다 데이터구조가 어떻게 작동하는지에 초점을 맞춘 것)
- A key can be used to indicate the priority of a value( key: can be used to indicate the priority of a value)
Each entry in the P.Q is hence a pair of (key, value).
Main methods of the Priority Queue ADT
: insert(key,value) : insert an entry with key k and value x into PQ, and return the entry storing them
removeMin(): remove and returns the entry with the smallest key (smallest key indicates first priority)
Additional methods: min(): return the entry with the smallest key, but do not remove it
size(), isEmpty()
- 적용 예시: Auctions, Stock market
=> 이러한 우선순위 큐를 구현하기 위해 the entry object, the comparator object가 필요하다.
Entry ADT
: An entry in a priority queue is simply a key-value pair.
-> Priority queues store entries to allow for efficient insertion and removal based on keys.
that is, the entry in a priority queue is simply a key-value pair.
'Computer Science > Data Structure & Algorithm' 카테고리의 다른 글
[Data Structure] Map, Dictionary (0) | 2022.11.17 |
---|---|
[Data Structure] Trees, Binary Trees (2) | 2022.11.08 |
[Data Structure & Algorithm] Time Complexity - O(logn) (1) | 2022.11.08 |
[ Data Structures ]Hash, Hash Table (0) | 2022.11.05 |
[MIT 6.006 - Introduction to Algorithms ] 2. Data Structure and Dynamic Arrays (0) | 2022.01.21 |