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

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
+2

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

0
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
0
other than these pointers did we need to consider the modification in the head pointer also @thakur sir
+1

yes we consider for insertion at end of CSLL.

see this: http://www.geeksforgeeks.org/circular-singly-linked-list-insertion/

0
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...???
0

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 ??

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

But how it is 2...??
0

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.

0
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...!!
0
If we can draw the picture, please post that.
0

Please correct me if I'm wrong

0
Why  are you counting one for head = p ??
0
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.
0
Because head pointer is also modified at the end...!!
0
What will be if we don't change the head pointer ???
0
The first two operations are the must. No need for third operation.

Related questions

0 votes
0 answers
1
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
162,959 comments
65,791 users