priority-queue Questions
7
Solved
Why did they name PriorityQueue if you can't insertWithPriority? It seems very similar to a heap. Are there any differences? If no difference, then why was it named PriorityQueue and not Heap?
Samiel asked 19/5, 2011 at 22:51
6
Solved
I am trying to take in a List of strings and add them into a Priority Queue with Key and Value. The Key being the word and the value being the string value of the word. Then I need to sort the queu...
Emulation asked 26/4, 2015 at 1:26
5
Solved
There are some threads on Stack Overflow dealing with implementing priority queues in .Net and C#.
My issue is of a more basic nature: Why isn't there a priority queue out of the box in the .Net f...
Unlike asked 14/12, 2009 at 9:33
3
If I have a heapq which contains some elements like:
import heapq
class Element(object):
def __init__(self, name, val):
self.name = name
self.val = val
if __name__ == "__main__":
heap = []
...
Les asked 14/8, 2014 at 22:47
4
In the constructor of PriorityQueue, we can pass in a collection like List or Set, which builds the PriorityQueue in linear time.
However, this also means the PriorityQueue will use a default Comp...
Basilio asked 23/11, 2016 at 14:21
4
What is the complexity (big-oh) for the remove() function on the Priority Queue class in Java? I can't find anything documented anywhere, I think it's O(n), considering you have to find the element...
Huntress asked 4/10, 2012 at 1:8
3
I need it for an implementation of Dijkstra's algorithm, and I do have my own implementation but documenting my code would be easier with java's own classes.
Semitrailer asked 27/4, 2012 at 7:29
3
How do I make the print_queue work properly in Java? This is my own implementation of a queue.
Using Iterator() works fine, except it prints numbers in random order.
package data_structures_java ;
...
Lord asked 8/4, 2014 at 5:28
4
Solved
Python has Queue.PriorityQueue, but I cannot see a way to make each value in it unique as there is no method for checking if a value already exists (like find(name) or similar). Moreover, PriorityQ...
Zalea asked 13/5, 2011 at 20:5
7
Solved
I have the below struct:
struct node {
float val;
int count;
}
I have several objects of this struct. Now, I want to insert these objects into a priority queue of STL such that the priority queu...
Headstand asked 7/2, 2012 at 14:33
7
Solved
Does Java have an easy way to reevaluate a heap once the priority of an object in a PriorityQueue has changed? I can't find any sign of it in Javadoc, but there has to be a way to do it somehow, ri...
Gilda asked 3/4, 2009 at 16:58
4
Solved
I have a situation when a msg fails and I would like to replay that msg with the highest priority using python boto package so he will be taken first. If I'm not wrong SQS queue does not support pr...
Brotherton asked 10/3, 2015 at 17:29
1
The following is pseudocode implement depth-first search(DFS) with one stack and a large table to mark visited nodes:
DFS(N0):
StackInit(S)
S.push((N0, null))
if isGoal(N0) then do
return true
...
Pseudaxis asked 24/12, 2020 at 3:43
5
I was wondering if it was possible for me to find the index of a value in a PriorityQueue . Just to see what number it is "in line". Does anyone know?
Franfranc asked 15/5, 2012 at 2:39
4
Solved
I implemented an algorithm where I make use of an priority queue.
I was motivated by this question:
Transform a std::multimap into std::priority_queue
I am going to store up to 10 million elements...
Cabinet asked 23/1, 2017 at 13:38
10
Solved
Related questions:
Java PriorityQueue with fixed size
How do I use a PriorityQueue?
get indexes of n smallest elements in an array
Scala: Is there a way to use PriorityQueue like I would in Java...
Redding asked 24/10, 2011 at 15:28
3
Solved
In the .NET Framework in PresentationCore.dll, there is a generic PriorityQueue<T> class whose code can be found here.
I wrote a short program to test the sorting, and the results weren't gr...
Wallow asked 27/5, 2017 at 20:44
3
Solved
This site suggests that if I want to reverse-order my priority queues, the following code is what I should use:
#include <iostream>
#include <queue>
using namespace std;
class mycompa...
Vitrine asked 26/3, 2013 at 20:52
9
Solved
The default stl priority queue is a Max one (Top function returns the largest element).
Say, for simplicity, that it is a priority queue of int values.
Warn asked 13/3, 2010 at 17:35
3
TL;DR: When several CompletableFutures are waiting to get executed, how can I prioritize those whose values i'm interested in?
I have a list of 10,000 CompletableFutures (which calculate the data r...
Parochialism asked 8/8, 2020 at 8:33
10
Solved
What's faster: inserting into a priority queue, or sorting retrospectively?
I am generating some items that I need to be sorted at the end. I was wondering, what is faster in terms of complexity: ...
Yt asked 21/9, 2010 at 9:52
8
Solved
How can I remove the tail element of a priority queue? I am trying to implement beam search using a priority queue and once the priority queue is full, I want to remove the last element(the element...
Stillhunt asked 27/2, 2013 at 16:31
4
Solved
How can I preallocate a std::priority_queue with a container of type std::vector?
std::priority_queue<unsigned char, std::vector<unsigned char>> pq;
pq.c.reserve(1024);
Does not com...
Tipperary asked 24/3, 2015 at 15:1
6
Solved
I'm using a priority queue as a scheduler with one extra requirement. I need to be able to cancel scheduled items. This equates to removing an item from the middle of the priority queue.
I can't u...
Vehicle asked 19/1, 2011 at 17:17
8
Solved
This is not a homework.
I'm using a small "priority queue" (implemented as array at the moment) for storing last N items with smallest value. This is a bit slow - O(N) item insertion time. Current...
Silviasilviculture asked 29/5, 2010 at 4:11
© 2022 - 2024 — McMap. All rights reserved.