正在加载图片...
Heap Order Property Applying this logic,we arrive at the heap order property.In a heap,for every node X,the key in the parent of Xis smaller than (or equal to)the key in x,with the exception of the root (which is has no parent). Analogously,we can declare a (max)heap,which enables us to efficiently find and remove the maximum element,by changing the heap order property.Thus,a priority queue can be used to find either a minimum or a maximum,but this needs to be decided ahead of time.Heap Order Property ◼ Applying this logic, we arrive at the heap order property: In a heap, for every node X, the key in the parent of X is smaller than (or equal to) the key in X, with the exception of the root (which is has no parent). ◼ Analogously, we can declare a (max) heap, which enables us to efficiently find and remove the maximum element, by changing the heap order property. Thus, a priority queue can be used to find either a minimum or a maximum, but this needs to be decided ahead of time
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有