GateAI
Searching, Sorting and Hashing

GATE CSE 2014 Set 1 · Q39

NAT2 marksEasy

Time

The minimum number of comparisons required to find the minimum and the maximum of 100 numbers is _________.

Your answerNumerical answer

Enter a value to check

Solution

Step-by-step verified solution

Official answer: 148

Searching, Sorting and Hashing

To find both the minimum and the maximum of nn numbers simultaneously using the optimal pairwise comparison method:

  1. If nn is even, compare the first two elements to initialize the current minimum and maximum (requires 11 comparison).

  2. For the remaining n−2n - 2 elements, process them in pairs:

    • Compare the two elements in the pair (11 comparison).

    • Compare the smaller element with the current minimum (11 comparison).

    • Compare the larger element with the current maximum (11 comparison).

    This takes 33 comparisons for every pair, giving 32(n−2)\frac{3}{2}(n - 2) comparisons.

  3. Total comparisons formula for even nn:

    Total comparisons=1+32(n−2)=3n2−2\text{Total comparisons} = 1 + \frac{3}{2}(n - 2) = \frac{3n}{2} - 2
  4. Substituting n=100n = 100:

    Total comparisons=3(100)2−2=150−2=148\text{Total comparisons} = \frac{3(100)}{2} - 2 = 150 - 2 = 148

Thus, the minimum number of comparisons is 148.

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

This Searching, Sorting and Hashing previous year question is Q39 of the GATE CSE 2014 Set 1 paper. Find more GATE CSE PYQs on Searching, Sorting and Hashing in Algorithms, or browse all GATE CSE PYQs.

Free diagnostic

Where do you stand for GATE?

Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Searching, Sorting and Hashing PYQs now with no account.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

Searching, Sorting and Hashing in GATE CSE

Searching, Sorting and Hashing has 27 GATE CSE PYQs across 20 papers from 2012 to 2026. 4 of them are 2-mark NAT questions like this one, and GATE CSE 2014 Set 1 has 3.

How GATE tests Searching, Sorting and Hashing

More from GATE CSE 2014 Set 1

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2014 Set 1 · Q39 · NAT

The minimum number of comparisons required to find the minimum and the maximum of 100 numbers is …

Topic-wise GATE CS PYQs with verified steps

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.