GATE CS 2023 | Question 13
Programming & Data Structures › Structures & Unions · MCQ · 1 mark · Answer: D
- Question 13Programming & Data Structuresmcq1 markSLLdel deletes a node in a singly-linked list given a pointer to the node and to the head. DLLdel does the same for a doubly-linked list. With nodes, what is the worst-case time complexity?
- A.SLLdel is O(1) and DLLdel is O(n)
- B.Both are O(log n)
- C.Both are O(1)
- D.SLLdel is O(n) and DLLdel is O(1)✓
Answer: D
Solution
Answer: (D) SLLdel is O(n) and DLLdel is O(1) In a singly-linked list, deleting a given node needs its predecessor; the copy-next trick works except for the last node, so the worst case is (traverse from head). In a doubly-linked list, the node has a prev pointer, so deletion adjusts prev/next in . - A.
More GATE PYQ on Structures & Unions
All GATE CS Programming & Data Structures PYQ →Attempt GATE CS 2023 in real GATE exam mode
Full paper with a timer, the GATE interface and a topic-wise analysis — free.
Create free account →