Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
pdf
asdafg.pdf
In class exercise:
Please design a priority queue data structure, priority_queue_with_id, that allows the user to
modify priority and delete a data with a specific id efficiently. You can modify code from
cp::priority_queue. It should have the following structure
template <typename T, typename Comp = std::less<T>>
class priority_queue with_id {
protected:
T*
mData;
size_t mCap;
size_t mSize;
Comp mLess;
// TODO: Your additional variables here
public:
priority_queue with_id (const Comp& c = Comp())
{ ... }
{ ... }
{ ... }
{ ... }
{ ... }
{ ... }
Hint: You can use stl::map to help, and achieve O(log2 n) or you can do better and be
O(log n)
dummy.pdf