How can a node be inserted in the middle of a linked list?

Skill/Topic: Linked List
A) by repointing the previous and the next elements of existing nodes to the new node
B) by repointing only the next elements of existing node to the new node
C) by repointing only the Previous elements of existing node to the new node
D) None of the above
Explanation: by repointing the previous and the next elements of existing nodes to the new node You can insert a node in the middle of a linked list by repointing the previous and the next elements of existing nodes to the new node.

Showing Answers 1 - 13 of 13 Answers

samiksc

  • Jan 23rd, 2006
 

(D) None of the above:

Four operations are required:

  1. prev of new node has to point to current node
  2. next of new node has to point to next node
  3. prev of the next node has to point to the new node
  4. next of current node has to point to the new node

  Was this answer useful?  Yes

Pt

  • Jul 10th, 2007
 

newNode-> link = current -> link
current -> link =newNode

  Was this answer useful?  Yes

sri

  • Nov 11th, 2007
 

firstly,  create a temporary node say "temp"!!!
so,    prev->link=temp;
         temp->link=next;

  Was this answer useful?  Yes

1. Identify where to be inserted.
2. nxt pointer of the new node to the next node.
3. nxt pointer of the previous node to the new node.

Do consider spl. cases :

1. to insert at the start of the list
2. to insert at the end of the list

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions