I am using a priority_queue<unsigned long,vector<unsigned long>,greater<unsigned long> > in C++ and I have a memory limit of 16MB. My program only needs 10MB, but as soon as it gets to 8653464 Bytes it tries to double its capacity and throws a bad_alloc.
Is there a way to stop this using my current implementation? Can a priority_queue have log(n) time still if I switch to a deque [from a vector]?
Switching to
dequeis very sensible approach. It grow by fixed number, not by x2 asvector. And complexity should stayO(log N).