GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Concepts  >  Data Structures
Go To First  |  Previous Question  |  Next Question 
 Data Structures  |  Question 70 of 202    Print  
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.



  
Total Answers and Comments: 5 Last Update: December 28, 2007   
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
January 23, 2006 07:42:33   #1  
samiksc Member Since: October 2005   Contribution: 233    

RE: How can a node be inserted in the middle of a link...

(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

 
Is this answer useful? Yes | No
February 06, 2007 07:16:14   #2  
sivanesh.a Member Since: December 2006   Contribution: 189    

RE: How can a node be inserted in the middle of a link...
ans : A.
 
Is this answer useful? Yes | No
July 10, 2007 10:26:49   #3  
Pt        

RE: How can a node be inserted in the middle of a link...
newNode-> link current -> link
current -> link newNode

 
Is this answer useful? Yes | No
November 11, 2007 05:15:50   #4  
sri        

RE: How can a node be inserted in the middle of a link...
firstly create a temporary node say "temp"!!!
so prev->link temp;
temp->link next;

 
Is this answer useful? Yes | No
December 28, 2007 01:30:36   #5  
manishmodgil Member Since: July 2006   Contribution: 15    

RE: How can a node be inserted in the middle of a linked list?
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

 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape