开发者

Percolate down/sift down a binary heap heuristic

开发者 https://www.devze.com 2023-01-27 09:59 出处:网络
Is there any optimizations in choosing which child node to percolate down in a binary heap?For example, in a min heap, if the parent no开发者_StackOverflowde was 10 and its children was 8 and 3 what w

Is there any optimizations in choosing which child node to percolate down in a binary heap? For example, in a min heap, if the parent no开发者_StackOverflowde was 10 and its children was 8 and 3 what would be the better node to swap with?

Choosing to swap with the larger child seems like it would increase the likelihood of stopping since child nodes below it would be greater than 8. Has there been any research done on this?


I realized this was a silly question as swapping with the larger element would actually violate the min heap property because 8 would have a child which has value 3.

0

精彩评论

暂无评论...
验证码 换一张
取 消