Question 11Asked in UGC NET Computer Science, August 2016 (Paper II & III, Selected Questions)

Consider an implementation of unsorted single linked list. Suppose it has its representation with a head and a tail pointer (i.e. pointers to the first and…

Consider an implementation of unsorted single linked list. Suppose it has its representation with a head and a tail pointer (i.e. pointers to the first and last nodes of the linked list). Given the representation, which of the following operation can not be implemented in O(1) time?
  1. AInsertion at the front of the linked list
  2. BInsertion at the end of the linked list
  3. CDeletion of the front node of the linked list
  4. DDeletion of the last node of the linked list
Show answerHide answer

Correct answer: (D) Deletion of the last node of the linked list

Explanation

Although we have a tail pointer, it is of no use for deletion because there is no previous pointer. To delete the last node we need a pointer to the second-last node so that it can become the new last node; finding it requires traversing the whole list, which takes O(n) time.

From UGC NET Computer Science PYQ, August 2016 (Paper II & III, Selected Questions)

This is question 11 of UGC NET Computer Science PYQ, August 2016 (Paper II & III, Selected Questions). See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.