What is the time complexity for deletion from a Maximum Heap? A. O(l) B. O(log n
ID: 3841409 • Letter: W
Question
What is the time complexity for deletion from a Maximum Heap? A. O(l) B. O(log n) C. O(n) D. O(n log n) E. O(n^2) What is the time complexity for creating a Minimum/Maximum Heap by inserting all the given elements one by one? A. O(l) B. O(log n) C. O(n) D. O(n log n) E. O(n^2) What is the time complexity for creating a Minimum/Maximum Heap by using the Heapify method? A. O(l) B. O(log n) C. O(n) D. O(n log n) E. O(n^2) What is the time complexity for searching a key from a Hash Table? A. O(l) B. O(log n) C. O(n) D. O(n log n) E. O(n^2) What is the time complexity for insertion to a Hash Table without collisions? A. O(l) B. O(log n) C. O(n) D. O(n log n) E. O(n^2)
Explanation / Answer
12.)Deletion from a max heap takes O(log n) as it requires swapping of root element with the last element which takes O(1) but it requires heapify of the tree which require O(log n). Therefore, option b is correct.
13.) Inserting a key in heap requires heapify of the tree which requires O(log n) for 'n' elements, it will take time O(n log n). Therefore, option d is correct.
14.) Building heap will take O(n).
15.) In worst case, when there are too many elements for a same key it will take O(n).
16.) Insertion to a hash table without collisions takes O(1) as it require O(1) to search the place.
Hope it helps, do give your valuable response.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.