1,428 views
0 votes
0 votes
Consider the following statements

I: The depths of any two leaves in a max heap differ by at most 1.
II: Inserting an element into a binary search tree of size n always takes O(log n) time.
Which of the above statements is/are true ?

1 Answer

Best answer
0 votes
0 votes
first statement is true.. as heap fill it level by level.. also said to be complete binary tree..
for the second statement,  as binary search tree either can be left skewed or right skewed in worst case.. so in that case insertion will take O (n).. so this statement is false...
selected by

Related questions

0 votes
0 votes
0 answers
1
akshayaK asked Dec 21, 2018
355 views
Why do we need a Build Heap procedure ?if we want to build a heap, we will call max_heapify on root node and we will form a heap in O(log N) TC.if we use build heap, it w...
0 votes
0 votes
1 answer
2
Shiv Gaur asked Aug 20, 2018
826 views
In a min heap time complexity for1: Find the 7th smallest element2: Delete the 7th smallest element