Is it possible to have a Priority Queue with the same key?
so have entries like <100, buy> <100, sell>. then when I have entries with the same key when a buy and sell of that key exists, remove those entries. I am thinking it would work with like an if Statement
If <100, buy> && <100, sell>{ then remove those two entries from queue; }
Someth开发者_如何学运维ing like that.
Q. Is it possible to have a Priority Queue with the same key?
A. Yes it can, However please refer to comments under question there are efficient solutions suggested for your task.
Check slide number 3 for more detail,
http://ww3.algorithmdesign.net/handouts/Heap.pdf
Happy coding!
精彩评论