GATE Computer ScienceHardGATE CSE · ISRO
What is the minimum number of comparisons needed in the worst case to find both the maximum and the minimum of 101 distinct numbers using the best known pairing strategy?
- A. 200
- B. 148
- C. 150
- D. 152
Correct answer: C. 150
Compare elements in pairs (50 comparisons), initialise with the odd element, then 3 comparisons per pair thereafter: ⌈3n/2⌉ − 2 = ⌈151.5⌉ − 2 = 150.
Practise more Programming and Data Structures (GATE) questionsProgramming and Data Structures (GATE): notes and key points
More Programming and Data Structures (GATE) questions
- The KMP failure (prefix) function π[i] of pattern P = "abaabaabaabab" gives, for each prefix P[0..i], the length of its longest proper…
- A hash table with 7 buckets uses separate chaining, h(k) = k mod 7, and every new key is inserted at the head of its chain. The keys 50…
- A hash table of size 13 uses double hashing: the i-th probe for key k is (k mod 13 + i·(1 + k mod 11)) mod 13. The keys 18, 41, 22, 44…
- Keys 40, 20, 60, 10, 30, 50, 70, 5, 15, 25, 35, 45, 55, 65, 80, 3, 12, 23, 27, 90 are inserted into an empty BST. How many nodes have a…
- In a knockout (tournament-tree) method, what is the minimum number of comparisons needed in the worst case to find both the smallest and…
- A binary heap stored in A[1..200] has the usual shape (complete binary tree, children of i at 2i and 2i+1). Taking the height of a leaf as…