GATE / CS ARCHIVE

GATE CSE 2016 SET 2 / QUESTION 15

GATE CSE 2016 Set 2 Q15

Data Structures · Arrays & Linked Lists · Full GATE CSE 2016 Set 2 paper

GATE 2016 Set 2, Q15 1 mark · MCQ
Report issue

Arrays & Linked Lists

Question 15, GATE 2016: A sorted doubly linked list initially holds N items. Delete and decrease-key receive pointers to their records. An algorithm performs, in order, Θ(N) deletes, O(log N) inserts, O(log N) finds and Θ(N) decrease-key operations. Select total time: A O(log²N); B O(N); C O(N²); D Θ(N² log N).
Tap to enlarge
Your answer
Answer & solution

Official answer: C

With the node pointer, doubly linked deletion is O(1). Maintaining sorted order can require O(N) search per insertion, find, or decrease-key repositioning. Thus Θ(N) deletions cost O(N), O(log N) insert/find calls cost O(N log N), and Θ(N) decreases cost O(N²) in the worst case. Total O(N²), C; the deletion count may leave Θ(N) elements, allowing this worst case.

A pointer removes the need to locate a node for deletion, but decreasing its key may move it far left to preserve order. Relinking is constant time; locating the new position can be linear. A linked list does not permit constant-time access to a middle index, so sortedness alone does not give array-style logarithmic binary search.

Original paper, page 29 · Answer key