Back to course home
0% completed
Vote For New Content
We don't want to use heapify since that would be O(K), but we use heap.index(ele...
Taimur
Jul 15, 2022
We don't want to use heapify since that would be O(K), but we use heap.index(element) to get the index of the element, and that would take O(K) as well, right? So overall time complexity wise it does not really matter, right?
1
0
Comments
Comments
Design Gurus3 years ago
Are you talking about following comments?
we can use heapify to readjust the elements but that would be O(N),
instead, we will adjust only one element which will O(logN)
heapify will take O(N) and not O(K)
but if we use _siftup() and _siftup() operations, they ta...
A
Andrew Leung3 years ago
If the size of either heap is O(k) however, won't heapify take O(k)?
Design Gurus3 years ago
Yes, if the heap size is 'K', then hepify will take O(K). Sorry about the confusion.
Actually, if we want to heapify just one element, it should take O(logK) actually. See this post: [https://www.geeksforgeeks.org/time-complexity-of-building-a-heap/](https://www.geeks...
On this page