Heap – Data Structure

Heap – Data Structure

Question 1 UGC NET June-2020
In a binary max heap containing n numbers, the smallest element can be found in_____ time.
A – O(n)
B – O(log2 n)
C – O(1)
D – O(log2 log2 n)

Show Answer With Best Explanation

Answer : a
Explanation:
In a binary MAX heap , smallest value of heap will always be present at the last level of heap, we have to search all the element to reach at last level. Since heap is using linear search , so time complexity to find smallest element from MAX heap is O(n).


error: Content is protected !!
Open chat
1
Hi,how Can We Help You ?