3. N elements are inserted from a min-heap with N elements. The total running time is:
a) O(N2) worst case
b) O(logN) worst case
c) O(N) worst case
d) None of these
Answer 3.)
(c) O(N) - Worst case
When N elements are inserted in a min-heap with N elements, the time complexity for this is O(LogN) - in worst case (in general). So, it will take Θ(NlogN) time.
But O(N) is the most appropriate answer.
The solution of time complexity O(N) takes the min-heap with N elements and other 'N' elements are to be inserted. It will construct min-heap in O(2N).
O(2N) can be written in the form O(N).
So, the total running time when N elements are inserted in a min-heap with N elements is O(N).
3. N elements are inserted from a min-heap with N elements. The total running time is:...
C++ Question 9 5 pts Deleting the minimum element in a min-heap of N elements takes in average case O(N log N) O(1) O(N) Oſlog N) D Question 10 5 pts The time taken to find an element in an AVL tree of depth d is Old) 02) Oſlog d) Old log d) Question 11 5 pts Secondary clustering in a hash table occurs when using Linear probing Separate chaining Quadratic probing Double hashing Question 12 5 pts When sorting...
C++ Question 5 5 pts In a min-heap of N elements, if we want to find the max element, we have to search all the leaves. What is the big-o running time of findMax? O(N^2) Oſlog N) O(N) OIN log N) Question 6 5 pts An AVL tree is a Binary Search Tree that has the following additional property for every node in the tree, the height of the left and right subtrees is the same none of the above...
What is the worst case running time of the following pseudo-code. void doSomething(int n, int m) { if(m> n) return; System.out.println("m=" + m); doSomething(n, m+2); } A o(n) B O(nlogn) C O(n2) D O(n+m) E None of the above
Give the psuedo code for inserting and deleting an element in a binary min heap and binary max heap data structure. Discuss the worst case running time for each pseudo code.
what is the worst case run time when finding the maximum value in a binary min heap(implemented using array ) containing N elements? worst case run time: explain:
1. In a heap, the upper bound on the number of leaves is: (A) O(n) (B) O(1) (C) O(logn) (D) O(nlogn) 2. In a heap, the distance from the root to the furthest leaf is: (A) θ(nlogn) (B) θ(logn) (C) θ(1) (D) θ(n) 3. In a heap, let df be the distance of the furthest leaf from the root and let dc be the analogous distance of the closest leaf. What is df − dc, at most? (A) 1 (C)...
5. A three-heap with n elements can be stored in an array A, where A[O] contains the root of the tree. a) Draw the three-heap that results from inserting 5, 2, 8, 3, 6, 4, 9, 7, 1 in that order into an initially empty three-heap. You do not need to show the array representation of the heap. You are only required to show the final tree, although if you draw intermediate trees. b) Assuming that elements are placed in...
7. What is the worst-case running time complexity of an algorithm with the recurrence relation T(N) = 2T(N/4) + O(N2)? Hint: Use the Master Theorem.
(e) 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. (f) Is it possible to find the maximum in a min-heap in O(log n) time? Justify. Important Notes: • For part (e) of this problem, you must draw the min (or max) heaps using the appropriate graphics tools at your convenience.
Is it possible to find the maximum in a min-heap in O(log n) time? Justify.