Effective Priority List

I am looking for an effective data structure to represent a list of priorities. In particular, I need to prioritize a set of items and return only the top scoring items. I looked at the priority queues that work on heaps, but they don't seem to satisfy my needs. They will reorganize the heap structure as soon as I interrogate the top ranking element from the queue.

The simplest solution, of course, would be a linked list, which in the worst case would take quite a while for the insert operation.

Does anyone have a better solution?

+5
source share
4 answers

Heaps seem very suitable, and it seems that you are mistaken.

, x ( x n, btw?)

, , - x.

.

, .

, ( O (1)) . , .

min, min . logx.

( nlogx time) O (xlogx).

, ( x), .


, , .

( O (1)) .

, X- ( O (n) , ). , S.

, S, , S.

x n (, n/2 - ), , x n, -.

+4

. ? O (log n) ( ), O (1) [ ]. .

+4

k , , , k-, ( ).

Add() , , , . O (k) , , . , , O (1), , , 0 ( - ).

, , , , . ( ), k.

+4

JDK pqueue (java.util.PriorityQueue), .

, , . , ? ( ), PriorityQueue .

+1

All Articles