linked list - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


linked list

kudakwashekudakwashe Posts: 5Member
how do i insert and delete any node between the first node and last node in the list.


  • DipaleeDipalee Posts: 11Member
    If you want to insert "new" node after "current" node, then your logic would be
    new->next = current->next
    current->next = new

    if you want to delete "current" node which comes after "previous", then your logic would be
    previous = current
    current = previous->next
    previous->next = current->next

Sign In or Register to comment.