What is the time complexity for creating a ternary heap using swapping?

Category: QuestionsWhat is the time complexity for creating a ternary heap using swapping?
Editor">Editor Staff asked 4 weeks ago

What is the time complexity for creating a ternary heap using swapping?
 
(a) O (log n/ log 3)
 
(b) O (n!)
 
(c) O (n)
 
(d) O (1)
 
The question is from Ternary heap in chapter Heap of Data Structures & Algorithms I
 
The question was posed to me in class test.

1 Answers
Editor">Editor Staff answered 4 weeks ago

The correct answer is (c) O (n)
 
The explanation is: Ternary Heap can be formed by two swapping operations. Therefore, the time complexity for creating a ternary heap using two swapping operation is found to be O (n).