Question

Run times of insurting, extracting max and finding max: heap as a linked binary tree with...

Run times of insurting, extracting max and finding max:

heap as a linked binary tree with pointers.

heap as a linked list with pointers

Homework Answers

Answer #1

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.

  

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
(a) Consider an initially empty max-heap, where the following keys are to be inserted one at...
(a) Consider an initially empty max-heap, where the following keys are to be inserted one at a time: 11, 19, 23, 12, 13, 17, 13, 14, 18, and 33. Draw the tree that results after building this max-heap. (b) Show the result of inserting 10, 12, 1, 14, 6, 5, 8, 15, 3, 9, 7, 4, 11, 13, and 2, one at a time and in the giver order , into an initially empty binary min heap. (c) Show the...
Construct the binary max-heap for the keys given below. Once all the keys are inserted, perform...
Construct the binary max-heap for the keys given below. Once all the keys are inserted, perform the remove maximum operation and then display the binary heap in the array form Keys to insert: 6, 7, 12, 10, 15, 17, 5, 9, 11
Let T be a complete binary tree such that node v stores the entry (p(v), 0),...
Let T be a complete binary tree such that node v stores the entry (p(v), 0), where p(v) is the level number of v. Is tree T a heap? Why or why not? I know that a complete binary tree is a heap, but shouldn't we also take into consideration the values that it is storing into the tree: (p(v), 0)? The heap tree could be either a min-heap or max-heap. If we order the the value based of p(v)...
Write a alogorithem for delete a max heap tree. . Give an efficient algorithm for the...
Write a alogorithem for delete a max heap tree. . Give an efficient algorithm for the following problem. Tree-Successor • Input: A BST T and a node a of T • Output: The node b of T containing the smallest key larger than a.key. If there is no such b, the output should be NIL.
Is searching an element in a Binary Search Tree (BST) faster than finding an element in...
Is searching an element in a Binary Search Tree (BST) faster than finding an element in a Binary Tree? If yes, explain why? (this is for Java programing)
‏What is the output of the Euler tour in the normal binary search tree if the...
‏What is the output of the Euler tour in the normal binary search tree if the key insert order is 5 , 2 , 8 , 5 , 9 , 5 , 1 , 3 , 4 , 2 , 8 ? All keys equal to the node should be the right subtree of that node. ____________________________________________________________ ‏Construct the binary max - heap for the keys given below. Once all the keys are inserted, perform the remove maximum operation, and...
Suppose a binary tree stores integers. Write efficient methods (and give their Big-Oh running times) that...
Suppose a binary tree stores integers. Write efficient methods (and give their Big-Oh running times) that take a reference to a binary tree root T and compute a. the number of nodes with two children that contain the same value **JAVA**