in DS edited by
604 views
0 votes
0 votes

  1. Delete the duplicate node
  2. Delete the alternate duplicate node
  3. Delete the adjacent node
  4. None of these
in DS edited by
604 views

2 Answers

1 vote
1 vote
For consecutive nodes with same data all except the first node will be deleted. So, option D.
by

2 Comments

@Arjun Sir

In Question  it has given "If the data of all nodes of double linked list is same". So should i take doubly linked list with all the node with same value ?

After taking a example like above, i am getting all the adjacent node with same data is getting delete and even the first node is also getting deleted at last.

please clear my doubt here.

0
0
Oh. I didn't see that. In that case only the first node remains. But In that case the above code is dereferencing NULL pointer (second becomes null and second->prev is dereferenced). So runtime error should result.
2
2
0 votes
0 votes
All the nodes will be deleted except the first node if all the node value is same otherwise if two adjacent node contain the same value then one of them will be deleted which comes later.