-
Notifications
You must be signed in to change notification settings - Fork 412
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PriorityQueue's changePriority method works in linear time #83
Comments
Yeah, it's possible. But in order to do that without changing the interface we need to add another structure to keep track of the relation: item -> position in the heap and the code can get a little convoluted, but I'll put some thought into it. |
I think this can be achieved by overloading function PriorityQueue(initialItems) {
MinHeap.call(this, function (a, b) {
return self._items[a].priority < self._items[b].priority ? -1 : 1;
});
/* ... */
} |
@felipernb @eush77 I've made a pull reuest with proposed implementation, can you have a look and check it out. Link : #129 |
We can do better, namely in O(log n).
The text was updated successfully, but these errors were encountered: