GateAI
Searching, Sorting and Hashing

GATE CSE 2021 Set 1 · Q2

MCQ1 markMedium

Time

Let P be an array containing nn integers. Let tt be the lowest upper bound on the number of comparisons of the array elements, required to find the minimum and maximum values in an arbitrary array of nn elements. Which one of the following choices is correct?

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: C) t > n and t ≤ 3 ⌈ (n)/(2) ⌉

Searching, Sorting and Hashing

To find both the minimum and maximum elements in an arbitrary array of nn elements simultaneously, the optimal algorithm pairs up elements and compares them:

  1. Compare elements in pairs: ⌊n/2⌋\lfloor n/2 \rfloor comparisons.

  2. Compare the larger elements with the current maximum: ⌈n/2⌉−1\lceil n/2 \rceil - 1 comparisons.

  3. Compare the smaller elements with the current minimum: ⌈n/2⌉−1\lceil n/2 \rceil - 1 comparisons.

The optimal number of comparisons (the lowest upper bound tt) is:

  • For even nn: 1+3(n−2)2=3n2−2=3⌈n/2⌉−21 + \frac{3(n-2)}{2} = \frac{3n}{2} - 2 = 3\lceil n/2 \rceil - 2

  • For odd nn: 3(n−1)2=3⌊n/2⌋\frac{3(n-1)}{2} = 3\lfloor n/2 \rfloor

In all cases, for n≥2n \ge 2:

t=⌈3n2⌉−2=3⌈n2⌉−2≤3⌈n2⌉t = \left\lceil \frac{3n}{2} \right\rceil - 2 = 3\left\lceil \frac{n}{2} \right\rceil - 2 \le 3\left\lceil \frac{n}{2} \right\rceil

Also, since finding just the minimum requires n−1n - 1 comparisons and finding the maximum requires additional comparisons, we have t>nt > n for n>2n > 2.

Thus, the correct inequality range is t>nt > n and t≤3⌈n2⌉t \le 3\left\lceil \frac{n}{2} \right\rceil.

Hence, the correct option is (C).

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 Q2 of the GATE CSE 2021 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. 9 of them are 1-mark MCQs like this one, and GATE CSE 2021 Set 1 has 2.

How GATE tests Searching, Sorting and Hashing

More from GATE CSE 2021 Set 1

Share this solution

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

GateAI solution cardGATE CSE 2021 Set 1 · Q2 · MCQ

Let P be an array containing n integers. Let t be the lowest upper bound on the number of comparisons of the array elements, required to find the minimum and maximum values in an arbitrary array of n elements. Which one of the following choices is correct?

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.