Which of the following operations is performed more efficiently by doubly…

2008

Which of the following operations is performed more efficiently by doubly linked list than by linear linked list?

Answer: A. Deleting a node whose location is givenConceptThe time for a linked-list update depends on which neighbouring nodes are already reachable. A singly linked node stores only a next link, whereas a…

  1. A.

    Deleting a node whose location is given

  2. B.

    Searching an unsorted list for a given item

  3. C.

    Inserting a node after the node with a given location

  4. D.

    Traversing the list to process each node

Attempted by 810 students.

Show answer & explanation

Correct answer: A

Concept

The time for a linked-list update depends on which neighbouring nodes are already reachable. A singly linked node stores only a next link, whereas a doubly linked node stores both next and previous links.

When the target node itself is given, a backward link can remove the need to search for its predecessor; operations that already have the required node or must inspect every node gain no such asymptotic advantage.

Application

  1. Let x be the given node. Deleting x requires changing its predecessor’s next link so that it bypasses x.

  2. In a singly linked list, x does not identify its predecessor. Starting from the head to locate that predecessor takes O(n) time in the general case.

  3. In a doubly linked list, x.prev gives the predecessor directly. Updating x.prev.next and, when present, x.next.prev takes O(1) time.

  4. Therefore, deleting a node whose location is given is performed more efficiently by a doubly linked list.

Cross-check and contrast

  • Searching an unsorted list may inspect every node in either representation, so it is O(n) in both.

  • Inserting after a known node already has the splice point, so it is O(1) in both.

  • Traversing to process every node necessarily visits all nodes, so it is O(n) in both.

Result: deleting a node whose location is given is the operation with the asymptotic efficiency advantage.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Iocl Engineers Officers Grade A Paper 2

Loading lesson…