正在加载图片...
Simple Implementations There are several obvious ways to implement a priority queue.We could use a simple linked list performing insertions at the front and traversing the list to delete the minimum. Alternatively,we could insist that the list be kept always sorted. Another way of implementing priority queues would be to use a binary search tree.Recall that the only element we ever delete is the minimum.Repeatedly removing a node that is in the left subtree would seem to hurt the balance of the tree by making the right subtree heavy.Simple Implementations ◼ There are several obvious ways to implement a priority queue. We could use a simple linked list, performing insertions at the front and traversing the list to delete the minimum. ◼ Alternatively, we could insist that the list be kept always sorted. ◼ Another way of implementing priority queues would be to use a binary search tree. Recall that the only element we ever delete is the minimum. Repeatedly removing a node that is in the left subtree would seem to hurt the balance of the tree by making the right subtree heavy
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有