The Gateway to Computer Science Excellence
+4 votes

In a doubly linked list the number of pointers affected for an insertion operation will be

  1. 4
  2. 0
  3. 1
  4. Depends on the nodes of doubly linked list
in DS by Boss (32.5k points) | 5.6k views
Is option A correct??
According to me (D) should be the correct ans. Bcz it is not given that where are we going to insert the node in linked list. If we insert in middle then only 4 pointers will be affected.
Ya agreed ,option D is most likely to be correct
@Arjun Sir,

Is the given option d is correct?

I mean it depends on the nodes of doubly linked list or the location we are inserting.a node.
yes, I do not know what the question setter meant.

sir, Do we need to consider "Depends on the nodes of doubly linked list" same as "Depends on the NUMBER OF nodes of doubly linked list" ....

It should be " depend on position of  node( where to insert) ".

4 Answers

+8 votes
Answer D)

case 1: If insertion in beginning (assume starting node's pointer name is start)





total change 4

case 2:insertion in middle(assume after some node x)





total change 4

case 3: insertion at the end (end node be x)




total change 3
by Active (4.1k points)
+2 votes
option D will be more correct because they are not giving number of nodes in doubly linked list.

Since if Number of nodes in DLL is more than 2 nodes and if we want to insert node in begining of DLL then it may affect 3 pointers.

if th number of nodes in DLL is one , then it mayaffect 2 pointers.

So ultimately it depends on number of nodes in DLL.........
by Boss (41.9k points)
yes it is D which is correct option .

In this question , nothing is mention where to insert so it depends on the nodes of doubly linked list .. the node where to insert .

hence D is the only correct option :)
I do not think the question has any meaning :O
Sir why do you think the question doesn't contain any meaning.

Answer should be 'D' until they tell it explicitly where we are inserting.
If the number of nodes in DLL is one , then it may affect 3 pointers- (I)- Next pointer of old node. (II)- Prev pointer of new node. (III)- Next pointer of new node- It will point to Null.

Suggest me where am I wrong.
0 votes
Option D..It depends whether to insert at 1st,middle or at last.
by Active (2.7k points)
0 votes

For insertions in the middle of the list, to splice in a new node as follows:

A --- B
   ^^ splice M in here = M
M.prev = A
B.prev = M = B

Hence four pointer assignments take place. However, if the insertion be at the head or tail, then only two pointer assignments would be needed:

TAIL (insert M afterward) = M
M.prev = TAIL

Ans: D

by Loyal (7.2k points)
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,647 questions
56,497 answers
100,822 users