You are given pointers to first and last nodes of a singly linked list, which of the following operations are dependent on the length of the linked list?

13it33 - Data Structures MCQ Type Test

13it33 - Data Structures MCQ Type Test



Questions: 30  |  Attempts: 213   |  Last updated: Mar 20, 2022

  • The inorder and preorder traversal of a binary tree are d, b, e, a, f, c, g and a, b, d, e, c, f, g respectively. The postorder traversal of the binary tree is:

    You are given pointers to first and last nodes of a singly linked list, which of the following operations are dependent on the length of the linked list?

    You are given pointers to first and last nodes of a singly linked list, which of the following operations are dependent on the length of the linked list?

    You are given pointers to first and last nodes of a singly linked list, which of the following operations are dependent on the length of the linked list?

    You are given pointers to first and last nodes of a singly linked list, which of the following operations are dependent on the length of the linked list?

You are given pointers to first and last nodes of a singly linked list, which of the following operations are dependent on the length of the linked list?

  1. Delete the first element
  2. Insert a new element as a first element
  3. Delete the last element of the list
  4. Add a new element at the end of the list

Answer is
Delete the last element of the list

Discussion Forum

Que.You are given pointers to first and last nodes of a singly linked list, which of the following operations are dependent on the length of the linked list?
a.Delete the first element
b.Insert a new element as a first element
c.Delete the last element of the list
d.Add a new element at the end of the list
Answer:Delete the last element of the list

You are given pointers to first and last nodes of a singly linked list, which of the following operations are dependent on the length of the linked list?
(A) Delete the first element
(B) Insert a new element as a first element
(C) Delete the last element of the list
(D) Add a new element at the end of the list

Answer: (C)


Explanation: a) Can be done in O(1) time by deleting memory and changing the first pointer.

b) Can be done in O(1) time, see push() here

c) Delete the last element requires pointer to previous of last, which can only be obtained by traversing the list.

d) Can be done in O(1) by changing next of last and then last.

Quiz of this Question

Practice Tags :

Please log in or register to answer this question.

Please log in or register to add a comment.