algorithm - Java: priority queue (or min-heap) with O(log n) deletion of arbitrary node -


i've got bunch of items i'm storing in min-heap (via priorityqueue), , have need efficiently delete arbitrary items. know in standard min-heap implementation, deleting arbitrary element (given know position of element in heap) takes o(log n) time, while finding position o(n). so, basically, need keep separate data structure holds each item's position in heap.

i more-or-less know how i'd implement scratch. i'm wondering if there's smart way utilize/subclass priorityqueue (which has other useful features) accomplish this.

update: clarify, need o(1) peek-min pq/min-heap affords.


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -