سوال ۶۳ کنکور ارشد علوم کامپیوتر ۱۴۰۳
در مورد ادغام لیست مرتب با مجموع تعداد اعضای ، کدام مورد درست است؟
پاسخ صحیح: گزینهٔ D — فقط به ازای هر مقدار ثابت این کار در زمان قابل انجام است.
Approach
We must merge already-sorted lists whose sizes sum to total elements, and decide for which values of the merge is achievable in time.
Key insight
A -way merge of sorted lists with total elements can be done in comparisons using a min-heap of size : each of the output elements costs one extract-min plus one insert. So the cost depends on :
- If is a constant , then .
- If grows with (e.g. with each list of size ), merging becomes equivalent to fully sorting elements, which needs in the comparison model — strictly worse than .
Evaluating the options
- "Only for ": false. gives , but so does any other constant (e.g. ). The word "only" is wrong.
- "For any arbitrary ": false. If is allowed to scale with , the merge degenerates into a comparison sort needing , which is not .
- "For , ": false. For a constant the merge is , not ; the blanket lower bound is incorrect.
- "Only for any constant , ": correct. is exactly achievable when (and only when) is a constant, since then is a constant factor.
Sanity check
Set , all singleton lists: a correct merge would sort arbitrary keys in linear comparisons, contradicting the comparison-sort lower bound. This rules out options 1 and 2 and confirms the constant- restriction in option 4.
Pitfall: Do not assume two-way merge () is the special boundary. The real boundary is " constant vs. growing": every fixed works in because collapses to a constant factor, while a growing reintroduces the factor of sorting.