✨ DAY 21: Priority Queue (Min-Max Heap + Heap Sort ✨
📌 Priority queues are a type of container adapters, specifically designed such that the first element of the queue is either the greatest or the smallest of all elements in the queue and elements are in nonincreasing order (hence we can see that each element of the queue has a priority {fixed order}). However in C++ STL, by default, the top element is always the greatest element. We can also change it to the smallest element at the top. Priority queues are built on the top to the max heap and uses array or vector as an internal structure.
✏️ 𝗙𝗼𝗿 𝗯𝗲𝘁𝘁𝗲𝗿 𝘂𝗻𝗱𝗲𝗿𝘀𝘁𝗮𝗻𝗱𝗶𝗻𝗴 𝗿𝗲𝗳𝗲𝗿 𝗳𝗼𝗹𝗹𝗼𝘄𝗶𝗻𝗴 𝗮𝗿𝘁𝗶𝗰𝗹𝗲𝘀 ;
- https://www.geeksforgeeks.org/priority-queue-in-cpp-stl/
- https://www.programiz.com/cpp-programming/priority-queue
- https://www.programiz.com/cpp-programming/priority-queue
- https://www.geeksforgeeks.org/implement-min-heap-using-stl/
- https://www.techiedelight.com/min-heap-max-heap-implementation-c/
- https://www.tutorialspoint.com/cplusplus-program-to-implement-max-heap
📽️ 𝗧𝘂𝘁𝗼𝗿𝗶𝗮𝗹 𝗟𝗶𝗻𝗸𝘀;
- https://youtu.be/nJ6FdAIr_6g
- https://youtu.be/HqPJF2L5h9U
- https://youtu.be/XDxLEUgVDMM
- https://youtu.be/yAs3tONaf3s
- https://youtu.be/XzA5Ts_vXfw
👨💻 𝗤𝘂𝗲𝘀𝘁𝗶𝗼𝗻𝗶𝗻𝗴 𝗥𝗼𝘂𝗻𝗱: 👇
- Inplace Heap Sort https://leetcode.com/problems/sort-an-array/solutions/1705515/inplace-heap-sort-space-complexity-o1-time-complexity-onlogn/
- Implementation Of Min Heap https://www.geeksforgeeks.org/implement-min-heap-using-stl/
- Implementation Of Max Heap https://www.tutorialspoint.com/cplusplus-program-to-implement-max-heap