DSA-in-December

✨ 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.

✏️ 𝗙𝗼𝗿 𝗯𝗲𝘁𝘁𝗲𝗿 𝘂𝗻𝗱𝗲𝗿𝘀𝘁𝗮𝗻𝗱𝗶𝗻𝗴 𝗿𝗲𝗳𝗲𝗿 𝗳𝗼𝗹𝗹𝗼𝘄𝗶𝗻𝗴 𝗮𝗿𝘁𝗶𝗰𝗹𝗲𝘀 ;

  1. https://www.geeksforgeeks.org/priority-queue-in-cpp-stl/
  2. https://www.programiz.com/cpp-programming/priority-queue
  3. https://www.programiz.com/cpp-programming/priority-queue
  4. https://www.geeksforgeeks.org/implement-min-heap-using-stl/
  5. https://www.techiedelight.com/min-heap-max-heap-implementation-c/
  6. https://www.tutorialspoint.com/cplusplus-program-to-implement-max-heap

📽️ 𝗧𝘂𝘁𝗼𝗿𝗶𝗮𝗹 𝗟𝗶𝗻𝗸𝘀;

  1. https://youtu.be/nJ6FdAIr_6g
  2. https://youtu.be/HqPJF2L5h9U
  3. https://youtu.be/XDxLEUgVDMM
  4. https://youtu.be/yAs3tONaf3s
  5. https://youtu.be/XzA5Ts_vXfw

👨‍💻 𝗤𝘂𝗲𝘀𝘁𝗶𝗼𝗻𝗶𝗻𝗴 𝗥𝗼𝘂𝗻𝗱: 👇

  1. Inplace Heap Sort https://leetcode.com/problems/sort-an-array/solutions/1705515/inplace-heap-sort-space-complexity-o1-time-complexity-onlogn/
  2. Implementation Of Min Heap https://www.geeksforgeeks.org/implement-min-heap-using-stl/
  3. Implementation Of Max Heap https://www.tutorialspoint.com/cplusplus-program-to-implement-max-heap