Suppose you want to delete the name that occurs before ‘Vivek’ in an alphabetical listing. Which one of the following data structures shall be most efficient for this operation?
Show the worked solutionAfter locating the node for 'Vivek', we need to delete its predecessor. In a doubly linked list the predecessor is reached by one prev pointer and can be unlinked in \(O(1)\) by fixing the pointers of its two neighbours.(A) and (C) A singly linked or circular list has only next pointers, so finding the node before 'Vivek' (and the one before that, to relink) needs another traversal — less efficient.(D) A deque only supports operations at its two ends, not in the middle of the list — incorrect.Answer: B
GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com