GateAI
Linear Structures, Trees and Heaps

GATE CSE 2016 Set 2 · Q15

MCQ1 markMedium

Time

NN items are stored in a sorted doubly linked list. For a delete\textit{delete} operation, a pointer is provided to the record to be deleted. For a decrease-key\textit{decrease-key} operation, a pointer is provided to the record on which the operation is to be performed. An algorithm performs the following operations on the list in this order: Θ(N)\Theta(N) delete\textit{delete}, O(log⁡N)O(\log N) insert\textit{insert}, O(log⁡N)O(\log N) find\textit{find}, and Θ(N)\Theta(N) decrease-key\textit{decrease-key}. What is the time complexity of all these operations put together?

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: C) O(N2)

Linear Structures, Trees and Heaps

Let us analyze the worst-case time complexity of each set of operations on a sorted doubly linked list of size up to NN:

  1. Θ(N)\Theta(N)delete operations: Given a pointer to the record to be deleted in a doubly linked list, deletion takes O(1)O(1) time per operation.

    Θ(N)×O(1)=O(N)\Theta(N) \times O(1) = O(N)
  2. O(log⁡N)O(\log N)insert operations: In a sorted linked list, finding the correct position takes O(N)O(N) time in the worst case, and updating pointers takes O(1)O(1).

    O(log⁡N)×O(N)=O(Nlog⁡N)O(\log N) \times O(N) = O(N \log N)
  3. O(log⁡N)O(\log N)find operations: Searching in a linked list takes O(N)O(N) time per operation.

    O(log⁡N)×O(N)=O(Nlog⁡N)O(\log N) \times O(N) = O(N \log N)
  4. Θ(N)\Theta(N)decrease-key operations: Given a pointer to the node whose key decreases, the node must be shifted towards the head of the sorted list to restore sorted order, which takes O(N)O(N) time per operation in the worst case.

    Θ(N)×O(N)=O(N2)\Theta(N) \times O(N) = O(N^2)

Total time complexity for all operations together is:

O(N)+O(Nlog⁡N)+O(Nlog⁡N)+O(N2)=O(N2)O(N) + O(N \log N) + O(N \log N) + O(N^2) = O(N^2)

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 Linear Structures, Trees and Heaps previous year question is Q15 of the GATE CSE 2016 Set 2 paper. Find more GATE CSE PYQs on Linear Structures, Trees and Heaps in Programming and Data Structures, 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 Linear Structures, Trees and Heaps 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.

Linear Structures, Trees and Heaps in GATE CSE

Linear Structures, Trees and Heaps has 14 GATE CSE PYQs across 12 papers from 2012 to 2026. 7 of them are 1-mark MCQs like this one, and it is the only one in GATE CSE 2016 Set 2.

How GATE tests Linear Structures, Trees and Heaps

More from GATE CSE 2016 Set 2

Share this solution

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

GateAI solution cardGATE CSE 2016 Set 2 · Q15 · MCQ

N items are stored in a sorted doubly linked list. For a delete operation, a pointer is provided to the record to be deleted. For a decrease-key operation, a pointer is provided to the record on which the operation is to be performed. An algorithm performs the following operations on the list in this order: (N) delete, O(log N) insert, O(log N) find, and (N) decrease-key. What is the time complexity of all these operations put together?

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.