C++

std::priority_queue

Në shqip përdoret i njëjti emër.

ShpjegimiSQ

priority_queue është një radhë ku del gjithmonë elementi më i madh (ose më i vogli, po ta konfigurosh). Nga brenda është një „heap“. Përdoret në algoritmin e Dijkstra-s, planifikim detyrash dhe gara programimi.

EnglishEN

priority_queue is a queue where the biggest item always comes out first (or the smallest, if you configure it). Under the hood it's a “heap”. It's used in Dijkstra's algorithm, task scheduling and programming contests.

Si ta mendosh

Si urgjenca në spital: s'hyn i pari që erdhi, por ai që ka më shumë nevojë.

Lexoje në anglisht

Like A&E at a hospital: not first come first served, but whoever needs it most.

Shembull kodicpp

std::priority_queue<int> pq;
pq.push(3); pq.push(9); pq.push(5);
std::cout << pq.top();   // 9

Terma të lidhur