Đang mở hậu trường...
Chọn đáp án để xem tỉ lệ cộng đồng và giải thích. Câu hỏi được chọn tự động — mọi người cùng làm 1 câu mỗi ngày.
You are building a service that must return the top K highest-scoring items out of N items (N >> K), and the request arrives repeatedly on a fresh batch each time. You compare two implementations: (A) maintain a min-heap of size K while scanning all N items, and (B) use Quickselect to partition around the K-th largest element, then sort only those K items. Which statement best captures the real trade-off between them?