Sunday, October 26, 2025
HomeData Modelling & AIData Structures | Misc | Question 3

Data Structures | Misc | Question 3

Which data structure is most efficient to find the top 10 largest items out of 1 million items stored in file?
(A) Min heap
(B) Max heap
(C) BST
(D) Sorted array

Answer: (A)
Explanation: Min heap of size 10 is sufficient to find the top 10 largest items. The algorithm can be given as follows:
1. Create the min heap with first 10 items.
2. For each remaining item, check if
2.1 The item is greater than the item stored in the head of the min heap.
2.1.1 If yes, replace it with this new item. Balance the min heap.
2.1.2 If no, do nothing.

At last, the min heap will contain the top 10 largest items.

Feeling lost in the world of random DSA topics, wasting time without progress? It’s time for a change! Join our DSA course, where we’ll guide you on an exciting journey to master DSA efficiently and on schedule.
Ready to dive in? Explore our Free Demo Content and join our DSA course, trusted by over 100,000 neveropen!

RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS