Run times of insurting extracting max and finding max heap a
Run times of insurting, extracting max and finding max:
heap as a linked binary tree with pointers.
heap as a linked list with pointers
Solution
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.
