What is the time complexity for increasing priority of key in a maximum ternary heap of n elements?

Category: QuestionsWhat is the time complexity for increasing priority of key in a maximum ternary heap of n elements?
Editor">Editor Staff asked 1 month ago

What is the time complexity for increasing priority of key in a maximum ternary heap of n elements?
 
(a) O (log n/ log 3)
 
(b) O (n!)
 
(c) O (n)
 
(d) O (1)
 
This key question is from Ternary heap topic in chapter Heap of Data Structures & Algorithms I
 
I got this question during an interview.

1 Answers
Editor">Editor Staff answered 1 month ago

The correct choice is (a) O (log n/ log 3)
 
The explanation is: In order to increase the priority of an item in a ternary heap data structure having n elements, it performs upwards swapping. So the time complexity for worst case is found to be O (log n/ log 3).