What is the complexity of adding an element to the heap.

Category: QuestionsWhat is the complexity of adding an element to the heap.
Editor">Editor Staff asked 5 months ago

What is the complexity of adding an element to the heap.
 
(a) O(log n)
 
(b) O(h)
 
(c) O(log n) & O(h)
 
(d) O(n)
 
Asked question is from Heap topic in division Heap of Data Structures & Algorithms I
 
The question was posed to me during an interview.

1 Answers
Editor">Editor Staff answered 5 months ago

Right option is (c) O(log n) & O(h)
 
The best I can explain: The total possible operation in re locating the new location to a new element will be equal to height of the heap.


Notice: Trying to get property 'ID' of non-object in /home/fvckxqmi/public_html/wp-content/themes/blocksy/inc/single/single-helpers.php on line 17

Notice: Trying to get property 'ID' of non-object in /home/fvckxqmi/public_html/wp-content/themes/blocksy/inc/single/single-helpers.php on line 17

Notice: Trying to get property 'ID' of non-object in /home/fvckxqmi/public_html/wp-content/themes/blocksy/inc/single/single-helpers.php on line 17

Notice: Trying to get property 'ID' of non-object in /home/fvckxqmi/public_html/wp-content/themes/blocksy/inc/single/single-helpers.php on line 17
Articles: 40701