1 1 vote Deleting any random element in heap would take n+logn or n+n? Algorithms time-complexity + – Raghav Khajuria 1.4k views answer comment Share Follow Print See all 11 Comments 11 11 Comments reply Show 8 previous comments srestha commented Sep 17, 2018 reply Follow flag Is it not multiplying requires @Shaik? because we need both first finding and then heapify operation It is not an OR operation right? 0 0 replyShare nephron commented Sep 17, 2018 reply Follow flag No, addition is required not multiplication. U search an element in O(n) and then heapify it O(logn). Nlogn means u r repeating heapify function N times. 1 1 replyShare Shaik Masthan commented Sep 17, 2018 reply Follow flag @srestha mam because we need both first finding and then heapify operation yes, in normal language, but in Algorithms first loop finds ===>O(n) second heapify ===> O(log n) mam, nephron explained it very well 0 0 replyShare Please log in or register to add a comment.
0 0 votes The deletion of random element takes 0(n) + 0(logn) time. 0(n) as the array traverses to find the last element and assign it to the root; 0(logn) as the element swaps as per max/min heap condition and deletion takes for the root. rish1602 answered Jun 15, 2021 rish1602 comment Share Follow 0 reply Please log in or register to add a comment.