anyone can plzz provide the code as i am unable to figure out,how to implement the queue part???
so that it takes O(lgn) time for insrtion and deletion???
You need to use a data structure called heap, to get the insertions and deletions in the priority queue in O(log n) time
1 Like
can u provide me with the full code??
and also is there any STL in c++??
You asked for C, so that’s why @tijoforyou suggested heap - http://www.cs.cmu.edu/~adamchik/15-121/lectures/Binary%20Heaps/heaps.html . In C++ there is priority queue - http://www.cplusplus.com/reference/queue/priority_queue/
2 Likes
[1]
[1]: http://pastebin.com/VNmge4jw