1 votes 1 votes Deleting any random element in heap would take n+logn or n+n? Algorithms time-complexity + – Raghav Khajuria asked Sep 17, 2018 retagged Jun 18, 2022 by makhdoom ghaya Raghav Khajuria 523 views answer comment Share Follow See all 11 Comments See all 11 11 Comments reply Show 8 previous comments srestha commented Sep 17, 2018 reply Follow Share Is it not multiplying requires @Shaik? because we need both first finding and then heapify operation It is not an OR operation right? 0 votes 0 votes nephron commented Sep 17, 2018 reply Follow Share 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 votes 1 votes Shaik Masthan commented Sep 17, 2018 reply Follow Share @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 votes 0 votes Please log in or register to add a comment.
0 votes 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 See all 0 reply Please log in or register to add a comment.