Data Structures and Algorithms Quiz

Placewit
Sep 29, 2021

--

In a binary max heap containing n numbers, the smallest element can be found in time

A) 0(n)
B) O(logn)
C) 0(loglogn)
D) 0(1)

Solution :

A) is correct.
In a max heap, the smallest element is always present at a leaf node. So we need to check for all leaf nodes for the minimum value. Worst case complexity will be O(n)

         12
/ \
/ \
8 7
/ \ / \
/ \ / \
2 3 4 5

Thanks for Reading

Placewit grows the best engineers by providing an interactive classroom experience and by helping them develop their skills and get placed in amazing companies.

Learn more at Placewit. Follow us on Instagram and Facebook for daily learning.

--

--

Placewit
Placewit

Written by Placewit

Upskilling students for tech placements!

No responses yet