![]() |
Based on a priority heap, a Java PriorityQueue represents an unlimited priority queue. PriorityQueue does not directly handle range queries, but it does provide quick access to the element with the greatest priority. On the other hand, range queries may be executed by taking pieces from the PriorityQueue that fall within a certain range. In this article, we will learn how to perform range queries on a PriorityQueue in Java. Way to Perform Range Queries on a PriorityQueueTo retrieve entries from a PriorityQueue that fall within a certain range, we can use a range query. We can loop over the PriorityQueue and filter entries according to the range criterion to do this. Program to Perform Range Queries on a PriorityQueue in JavaLet’s construct an example in which we execute range queries on an integer containing PriorityQueue. Java
Output
Elements within the range 8 and 14: 8 10 12 14 Explanation of the above program:
|
Reffered: https://www.geeksforgeeks.org
Java |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 13 |