The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+3 votes

In circular singly linked list, insertion of node requires modification of how many pointers?

  1. 1 pointers
  2. 2 pointers
  3. 3 pointers 
  4. 4 pointers
asked in Programming by Active (2.8k points)
edited by | 971 views

it will require modification of 2 pointers viz. next of node N1 after which insertion is to be done and next of new node.

circular singly linked list or doubly.

In Singly: 2 pointers in middle, 1 in end

In Doubly: 4 pointers in middle , 2 in end

1 Answer

+3 votes
Best answer

for circular singly linked list,

answered by Boss (13.3k points)
selected by
other than these pointers did we need to consider the modification in the head pointer also @thakur sir

yes we consider for insertion at end of CSLL.

see this:

When I try to insert node at the beginning of CSLL, I have done the following steps:

We have made a new node pointed by p,

1) assign head to temp

2) traverse till temp->next != head, then assign temp->next = p...(1st modification)

3) now assign p->next = head....(2nd modification).

4) assign head = p...(3rd modification)

How ans is 2 pointers...???

traverse till temp->next != NULL, then assign temp->next = p...(1st modification)

Please Explain this. And Where is Null is the Above Diagram ???

Last node will contain the address of the first  node ??

Thankyou for correcting....Edited
I read only Singly Linked List not circular....

But how it is 2...??

Question is asking for the modification of the pointers.

As you are taking temp as the pointer. It is only for the traversing of the list.The actual modification will be in only two pointers.

when we insert at beginning, we are modifying last node's pointer, the node pointer which we have to insert and the head pointer....

I'm not counting temp pointer modification...!!
If we can draw the picture, please post that.

Please correct me if I'm wrong

Why  are you counting one for head = p ??
Here you are not doing to modification in the list. you are just shifting the head pointer.

If you will not do that then there is no problem because p will now work as the head pointer.
Because head pointer is also modified at the end...!!
What will be if we don't change the head pointer ???
The first two operations are the must. No need for third operation.

Related questions

0 votes
0 answers
asked Nov 20 in Programming by srestha Veteran (103k points) | 44 views

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

44,073 questions
49,595 answers
65,791 users