# Tag Archives: cpp-priority-queue

## Next greater number on the basis of precedence of digits

Given a number num containing n digits. The problem is to find the next greater number using the same set of digits in num on… Read More »

## Print Binary Tree levels in sorted order

Given a Binary tree, the task is to print its all level in sorted order Examples: Input : 7 / \ 6 5 / \… Read More »

## priority_queue emplace() in C++ STL

Priority queues are a type of container adaptors, specifically designed such that the first element of the queue is the greatest of all elements in… Read More »

## priority_queue::swap() in C++ STL

Priority queues are a type of container adaptors, specifically designed such that the first element of the queue is the greatest of all elements in… Read More »

## priority_queue::top() in C++ STL

Priority queues are a type of container adaptors, specifically designed such that the first element of the queue is the greatest of all elements in… Read More »

## priority_queue::push() and priority_queue::pop() in C++ STL

Priority queues are a type of container adaptors, specifically designed such that the first element of the queue is the greatest of all elements in… Read More »

## priority_queue::empty() and priority_queue::size() in C++ STL

Priority queues are a type of container adaptors, specifically designed such that the first element of the queue is the greatest of all elements in… Read More »

## Maximum distinct elements after removing k elements

Given an array arr[] containing n elements. The problem is to find maximum number of distinct elements (non-repeating) after removing k elements from the array.… Read More »

## Prim’s algorithm using priority_queue in STL

Given an undirected, connected and weighted graph, find Minimum Spanning Tree (MST) of the graph using Prim’s algorithm. Input : Adjacency List representation of above… Read More »

## Dijkstra’s Shortest Path Algorithm using priority_queue of STL

Given a graph and a source vertex in graph, find shortest paths from source to all vertices in the given graph. Input : Source =… Read More »

## How to implement Min Heap using STL?

In C++ STL, there is priority_queue that can directly be used to implement Max Heap. In order to fully understand the code, make sure you… Read More »

## Priority Queue in C++ Standard Template Library (STL)

Priority queues are a type of container adapters, specifically designed such that the first element of the queue is the greatest of all elements in… Read More »

## Sort a nearly sorted (or K sorted) array

Given an array of n elements, where each element is at most k away from its target position, devise an algorithm that sorts in O(n… Read More »