Question 22Asked in Bihar STET Paper 2 Computer Science (Class 11-12), 12 Sep 2023, Shift 2 + 1 more paper

In pointer implementation of linked lists, which operation can be performed in constant time (O(1)) when inserting or deleting nodes?

  1. AInserting at the beginning
  2. BInserting at the end
  3. CInserting at a specific position
  4. DDeleting a specific node
Show answerHide answer

Correct answer: (A) Inserting at the beginning

Explanation

Inserting at the beginning needs only to set newnode->next = head and head = newnode, which is O(1); inserting at the end or at a position requires traversal.

From Bihar STET Paper 2 Computer Science (Class 11-12) PYQ, 12 Sep 2023, Shift 2

This is question 22 of Bihar STET Paper 2 Computer Science (Class 11-12) PYQ, 12 Sep 2023, Shift 2. 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.

Asked in 2 papers