The GATE Grind

GATE 2016 CS (CS2) – Question 25

Programming and Data Structures · Linked Lists · 1 mark · Multiple choice

N records are in a sorted doubly linked list. Node pointers are supplied for delete and decrease-key. An algorithm performs, in order, $\Theta(N)$ deletes, $O(\log N)$ inserts, $O(\log N)$ finds, and $\Theta(N)$ decrease-key operations. What is their combined time complexity?

  1. $O(\log^2N)$
  2. $O(N)$
  3. $O(N^2)$
  4. $\Theta(N^2\log N)$

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: (C) $O(N^2)$

Explanation

A delete takes constant time with its pointer. Finding a key or an insertion position can take linear time. Decrease-key may require linear traversal to relocate the record and maintain sorted order. The Θ(N) decrease-key operations dominate at O(N²); the logarithmically many searches/inserts contribute O(N log N). Thus C.

More Linked Lists questions

All Linked Lists questions →