Which of the following data structure is used to implement a priority queue efficiently?
What is the time complexity of inserting an element into a priority queue implemented using a binary heap?
1 Crore+ students have signed up on EduRev. Have you? Download the App |
In a priority queue, the element with the highest priority is always placed at the:
Which of the following operations can be performed on a priority queue?
Which of the following is NOT a valid application of a priority queue?
What will be the output of the following code?
#include <iostream>
#include <queue>
int main() {
std::priority_queue<int> pq;
pq.push(10);
pq.push(5);
pq.push(15);
pq.push(3);
std::cout << pq.top();
return 0;
}
What will be the output of the following code?
#include <iostream>
#include <queue>
int main() {
std::priority_queue<int, std::vector<int>, std::greater<int>> pq;
pq.push(10);
pq.push(5);
pq.push(15);
pq.push(3);
std::cout << pq.top();
return 0;
}
What will be the output of the following code?
#include <iostream>
#include <queue>
int main() {
std::priority_queue<int> pq;
pq.push(10);
pq.push(5);
pq.push(15);
pq.push(3);
while (!pq.empty()) {
std::cout << pq.top() << " ";
pq.pop();
}
return 0;
}
What will be the output of the following code?
#include <iostream>
#include <queue>
int main() {
std::priority_queue<std::pair<int, int>> pq;
pq.push({1, 5});
pq.push({2, 3});
pq.push({3, 7});
pq.push({4, 1});
while (!pq.empty()) {
auto p = pq.top();
std::cout << "(" << p.first << ", " << p.second << ") ";
pq.pop();
}
return 0;
}
What will be the output of the following code?
#include <iostream>
#include <queue>
int main() {
std::priority_queue<int> pq;
pq.push(10);
pq.push(5);
pq.push(15);
pq.push(3);
pq.push(10);
std::cout << pq.size();
return 0;
}
What is the time complexity of finding the maximum element in a priority queue implemented using a binary heap?
Which of the following operations can be performed in constant time on a priority queue?
Which of the following data structures can be used to implement a priority queue other than a binary heap?
What will be the output of the following code?
#include <iostream>
#include <queue>
int main() {
std::priority_queue<int> pq;
pq.push(10);
pq.push(5);
pq.push(15);
pq.push(3);
pq.pop();
std::cout << pq.top();
return 0;
}
Which of the following is NOT a valid implementation of a priority queue?
153 videos|115 docs|24 tests
|
153 videos|115 docs|24 tests
|