You are given an array of 1024 elements, minimum number of comparisons…

You are given an array of 1024 elements, minimum number of comparisons required to find out second largest element among all will be _______.

Answer: A. 1032Concept: Finding the maximum of n elements via a knockout (tournament) arrangement always takes exactly n − 1 comparisons, since each comparison eliminates…

  1. A.

    1032

  2. B.

    2045

  3. C.

    1033

  4. D.

    2046

Attempted by 14 students.

Show answer & explanation

Correct answer: A

Concept: Finding the maximum of n elements via a knockout (tournament) arrangement always takes exactly n − 1 comparisons, since each comparison eliminates exactly one candidate and n − 1 eliminations must happen to leave a single winner. Because the second-largest element is bigger than every other element except the largest, the only element it can ever lose a comparison to is the actual largest, so the second-largest must be one of the elements the eventual champion played against directly during the tournament — never someone deeper down who was eliminated earlier by a third element.

  1. Comparisons to find the largest among n = 1024 elements = n − 1 = 1024 − 1 = 1023.

  2. In a balanced knockout bracket the champion plays exactly log2n rounds, so it faced at most log21024 = 10 opponents directly over the whole tournament.

  3. The second-largest must be among those (at most) 10 direct opponents of the champion, so finding the best of that group needs 10 − 1 = 9 comparisons.

  4. Total minimum comparisons = 1023 + 9 = 1032.

Cross-check: this matches the standard closed-form result for this problem — the minimum comparisons to find both the largest and second-largest of n elements by tournament method is n + ⌈log2n⌉ − 2. Substituting n = 1024 gives 1024 + 10 − 2 = 1032, confirming the same answer independently.

Explore the full course: Accenture Preparation

Loading lesson…