0% found this document useful (0 votes)
26 views

Insert at Any Specific Node in A Linked - List

The document describes how to insert a new node with a specified value into a linked list at a particular node. It involves: 1) Checking if the linked list is empty, and if so printing an error. 2) Traversing the linked list using a pointer until the node with the desired value is found. 3) Allocating memory for the new node, setting its value and link, and adjusting the pointers to insert it between nodes.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

Insert at Any Specific Node in A Linked - List

The document describes how to insert a new node with a specified value into a linked list at a particular node. It involves: 1) Checking if the linked list is empty, and if so printing an error. 2) Traversing the linked list using a pointer until the node with the desired value is found. 3) Allocating memory for the new node, setting its value and link, and adjusting the pointers to insert it between nodes.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

www.eazynotes.

com

Gursharan Singh Tatla

Page No. 1

INSERT AT ANY SPECIFIC NODE IN A LINKED LIST


Insert Specific ( ):
Description: Here START is a pointer variable which contains the address of first node. NEW is a pointer variable which will contain address of new node. N is the value after which new node is to be inserted and ITEM is the value to be inserted. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. ELSE PTR = PTR->LINK [End of Step 6 If] [End of While Loop] [End of Step 1 If] 14. Exit Else Set PTR = START, NEW = START Repeat While (PTR != NULL) If (PTR->INFO == N) Then NEW = New Node NEW->INFO = ITEM NEW->LINK = PTR->LINK PTR->LINK = NEW Print: ITEM inserted If (START == NULL) Then Print: Linked-List is empty. It must have at least one node

You might also like