Run times of insurting, extracting max and finding max:
heap as a linked binary tree with pointers.
heap as a linked list with pointers
Ans. heap as a linked binary tree:
insertion: O(log n) where n is the number of nodes in
the tree. log n is the height of the tree.
extracting max: O(log n)
extracting min: O(log n)
heap as a linked list:
insertion: O(n) where n is the number of nodes in the
list.
extracting max: O(n)
extracting min: O(1) if it is min heap, min would be present at the
head of the list.
Get Answers For Free
Most questions answered within 1 hours.