doubly linked list ERROR PRONE AREAS.

Revision en2, by vsanjay_nitdgp, 2015-08-20 21:41:20

recently i wrote a program on doubly linbked list.....this is my code

http://ideone.com/XLSln7

i coulod able to put number at any position except at end.....could you pls tell whats wrong in this code.

THIS WAS MY QUESTION ..BUT LATER I SAW THE CODE TWICE ....AND GOT THE ERROR..

i got it...in doubly linked list.....when you are inserting a noe at the end....see that you are not using thsi step...

"temp1->next->prev=temp1;"

so....take a global variable 'l' which keeps track of length of list....when list length is equal to your inserting position ,dont use that line....

check modified code below

http://ideone.com/mwEiyp

hope this helps for beginners of linked list.

Tags data structures

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English vsanjay_nitdgp 2015-08-20 21:41:20 495
en1 English vsanjay_nitdgp 2015-08-20 21:04:52 245 Initial revision (published)