COMP 352 Lecture 17: Priority Queue

79 views3 pages

Document Summary

Depending on the implementation used it affects the time complexity. The ones we have so far were proper binary tree. A heap complete binary tree stores keys, which satisfy the following properties. Heap order property: max: for every node valueother than root, key(value) <= key(parent(value)) Min: for every node valueother than root, key(value) >= key(parent(value)) ii. Let x be the height of the binary tree, then: the remaining nodes at depth h reside in the left most possible position in that. For i = 0, 1, h-1, there are 2inodes at depth i. Insertion takes place from left ii: the minimum is always at the root. Adding a value that is larger than parent causes upheap to execute. Upon doing this, the heap order property is not valid anymore. If the child is smaller than the parent, then you swap the parent with that child.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers