GateAI
Searching, Sorting and Hashing

GATE CSE 2015 Set 1 · Q40

MCQ2 marksMedium

Time

An algorithm performs (log⁡N)1/2(\log N)^{1/2} find operations, NN insert operations, (log⁡N)1/2(\log N)^{1/2} delete operations, and (log⁡N)1/2(\log N)^{1/2} decrease-key operations on a set of data items with keys drawn from a linearly ordered set. For a delete operation, a pointer is provided to the record that must be deleted. For the decrease-key operation, a pointer is provided to the record that has its key decreased. Which one of the following data structures is the most suited for the algorithm to use, if the goal is to achieve the best total asymptotic complexity considering all the operations?

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: A) Unsorted array

Searching, Sorting and Hashing

Let k=(log⁡N)1/2k = (\log N)^{1/2}. Note that k≪Nk \ll N.

Let us evaluate the total asymptotic time complexity for each candidate data structure:

  1. Unsorted array:

    • Insert: Insert at the end takes O(1)O(1) time   ⟹  N×O(1)=O(N)\implies N \times O(1) = O(N).

    • Delete (with given pointer): Swap with the last element and decrement size in O(1)O(1) time   ⟹  k×O(1)=O(k)\implies k \times O(1) = O(k).

    • Decrease-key (with given pointer): Update key in-place in O(1)O(1) time   ⟹  k×O(1)=O(k)\implies k \times O(1) = O(k).

    • Find: Linear scan of array takes O(N)O(N) time   ⟹  k×O(N)=O(N(log⁡N)1/2)\implies k \times O(N) = O(N(\log N)^{1/2}).

    • Total time: O(N+k+k+N(log⁡N)1/2)=O(N(log⁡N)1/2)O(N + k + k + N(\log N)^{1/2}) = O(N(\log N)^{1/2}).

  2. Min-heap:

    • Insert: O(log⁡N)  ⟹  Nlog⁡NO(\log N) \implies N \log N.

    • Delete / Decrease-key: O(log⁡N)  ⟹  klog⁡NO(\log N) \implies k \log N.

    • Find: O(N)  ⟹  kNO(N) \implies k N.

    • Total time: O(Nlog⁡N)O(N \log N). Since Nlog⁡N>N(log⁡N)1/2N \log N > N(\log N)^{1/2}, this is asymptotically slower.

  3. Sorted array / Sorted doubly linked list:

    • Insert: Takes O(N)O(N) time per insertion   ⟹  N×O(N)=O(N2)\implies N \times O(N) = O(N^2), which is much worse.

Therefore, the Unsorted array gives the minimum total asymptotic time complexity [p. 21, Q. 60].

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 Q40 of the GATE CSE 2015 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. 7 of them are 2-mark MCQs like this one, and it is the only one in GATE CSE 2015 Set 1.

How GATE tests Searching, Sorting and Hashing

More from GATE CSE 2015 Set 1

Share this solution

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

GateAI solution cardGATE CSE 2015 Set 1 · Q40 · MCQ

An algorithm performs (log N)1/2 find operations, N insert operations, (log N)1/2 delete operations, and (log N)1/2 decrease-key operations on a set of data items with keys drawn from a linearly ordered set. For a delete operation, a pointer is provided to the record that must be deleted. For the decrease-key operation, a pointer is provided to the record that has its key decreased. Which one of the following data structures is the most suited for the algorithm to use, if the goal is to achieve the best total asymptotic complexity considering all the operations?

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.