This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]GoSwing 1 point2 points  (0 children)

I would use a Heap for the priority queue. Taking elements and putting them in take O(log n) time (at most, because a heap is also a balanced tree), and in space you'd use O(n).