Computer Science EngineeringHard
The minimum number of comparisons needed to find both the largest and second-largest of 16 distinct elements (tournament method) is
- A. 15
- B. 18
- C. 17
- D. 19
Correct answer: B. 18
The tournament needs n-1 = 15 comparisons plus ceil(log2 n) - 1 = 3 more among the champion's opponents, totalling 18.
Practise more Algorithms, Data Structures & Programming (ISRO CS) questionsAlgorithms, Data Structures & Programming (ISRO CS): notes and key points
More Algorithms, Data Structures & Programming (ISRO CS) questions
- Which data structure follows the Last-In-First-Out principle?
- The height (in edges) of a complete binary tree having n nodes is
- The time needed to build a binary heap from n arbitrary elements using bottom-up heapify is
- The maximum number of nodes in a binary tree of height h (root at height 0) is
- The recurrence T(n) = 2T(n/2) + n log n solves to
- Consider int f(int n){ if(n<=1) return 1; return f(n-1)+f(n-2); }. What does f(6) return?